Skip to content

Running cucumber scenarios using TestNG (Scenario level) #1113

@deepnirmal

Description

@deepnirmal

Summary

When we run the Cucumber-jvm using TestNG, by default it runs each and every feature file as a single Test case. What I want is basically it should give functionality to run each and every scenario with examples as single test case.

Expected Behavior

I want to create screenshots of the test failure and I am currently using selenium with cucumber-testng. Selenium listener is used to capture the event and based on the event it captures the screenshots. But this happens only on a feature level, not at the scenario level.
My expectation is I want each scenario to be passed in @test such that if any scenarios fails. It should trigger the event for test fail such that my code would capture the event.

Current Behavior

It takes all the scenarios as a single test case. So my code is generating the screenshots if any scenarios fails in the feature and a single snap is generated for a particular feature file.
It runs the scenarios one after the other and doesn't trigger any event for the failure.

Possible Solution

By extending the feature of testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
such as
testNGCucumberRunner.runCucumberScenario(cucumberFeature.getFeatureScenario(scenarioname))

Steps to Reproduce (for bugs)

  1. Functionality for getting all scenarios name and examples
  2. Adding a method for running cucumber scenario by passing every scenario name
  3. Throw exception if the scenario name is not present
  4. Run every scenario as a @test kind

Context & Motivation

This will help in achieving the scenario level runtime options for the QA for handling events such as creating screenshots or onSuccess things to be done.
Feature level Test helps in solving the issues on modular level. But Scenario level test will help in achieving the sub-functionalities and various other uses cases per module.

Your Environment

  • Operating System and version: Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    🙏 help wantedHelp wanted - not prioritized by core team⚡ enhancementRequest for new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions