question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running cucumber scenarios using TestNG (Scenario level)

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Oct 25, 2017

Awesome. Works like a charm now 😃 Thanks I somehow missed the documentation.

0reactions
lock[bot]commented, Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parallel Execution - Cucumber Documentation
Cucumber can be executed in parallel using TestNG and Maven test execution plugins by setting the dataprovider parallel option to true. In TestNG...
Read more >
Running Cucumber Scenarios in Parallel & NOT Feature Files
In this article, we will see how to achieve parallelism in Cucumber Scenarios using TestNG Framework and learn the differences between JUnit ...
Read more >
How to implement and run cucumber test files using testng
Following Java code in Cucumber Runner Class worked perfectly for me to run each scenario as TestNG test in feature files:
Read more >
Cucumber Tags - Tools QA
How to run Cucumber Tests in Groups using Cucumber Tags? · Few scenarios are part of the Smoke Test, Regression Test, and End2End...
Read more >
[Cucumber-jvm][TestNG] How to get scenario info in testng ...
I am running my cucumber test using testng runner in RunCukesByCompositionTest style with testng hooks. I was trying to get all the tags...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found