Question

I've written a CucumberJVM test harness and a large set of feature files to test my application. Some of these tests can take 10 to 20 minutes to run which means that the test harness appears to hang for long periods of time.

To give my end users some confidence that the machine hasn't locked up, what I'd like to do at the start of each Scenario is to print the Scenario name. I know that the @Before can be used to define a glue method that will be executed before each test starts. So my question is:

"How can I get the Scenario name in a @Before annotated method"

Was it helpful?

Solution

I assume you are using the junit runner, so here's a simple example.

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "classpath:features/something.feature",
        format = "com.blah.PrintingFormatter",
        glue = "com.blah.steps")
public class CucumberTest {

}

Then your PrintingFormatter should implement the gherkin.formatter.Formatter interface, specifically the startOfScenarioLifeCycle method. Slap your println in there and you're good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top