Open
Description
🤔 What's the problem you're trying to solve?
Users may want to run the same suite of feature files against multiple browsers. Currently this can only effectively be done by defining an environment variable and running Cucumber multiple times.
With JUnit 5 and TestNG it is possible to define suites that define these parameters externally. E.g:
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("io/cucumber/examples/calculator")
@ConfigurationParameter(key = "projectname.browser", value = "firefox")
public class RunCucumberOnFirefoxTest {
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Run Cucumber" parallel="tests">
<test name="Cucumber on Firefox">
<parameter name="cucumber.features" value="classpath:io/cucumber/examples/calculator"/>
<parameter name="projectname.browser" value="firefox"/>
<classes>
<class name="com.example.RunCucumber"/>
</classes>
</test>
</suite>
However there is no easy way to access the projectname.browser
value within a Scenario.
✨ What's your proposed solution?
@Before
public void setupBrowser(Scenario scenario){
Optional<String> browser = scenario.configurationParameters().get("projectname.browser");
// Create browser here
}
We can use JUnit 5s ConfigurationParameters
interface for inspiration.
⛏ Have you considered any alternatives or workarounds?
- Launching multiple test executions
- Using a
ThreadLocal
to pass information to scenarios e.g: https://stackoverflow.com/a/76136072/3945473
📚 Any additional context?
Doing this properly would require rewriting Cucumbers RuntimeOptions
. Ideally cucumber would read properties on demand using the ConfigurationParameters
rather than parsing everything ahead of time. So probably something to consider for v8.