'@CucumberOptions in cucumber-junit-platform-engine
I'm trying to migrate my cucumber tests from cucumber-junit
to cucumber-junit-platform-engine
to be able to use new platform features. How do I redefine my runner to use old @CucumberOptions
. I'm investigating the issue but can't seem to find the proper way yet.
Before I used such options:
@CucumberOptions(
plugin = ...,
features = ...,
tags = ...,
glue = ...
)
Is there a straighforward way to migrate it to platform-engine?
Solution 1:[1]
Until Junit5/#2416 is merged there is no 1-to-1 replacement. However if you only have a single class annotated with @CucumberOptions
adding properties to junit-platform.properties
should suffice.
EDIT: #2416 was merged and released. You can now use suites to run cucumber with different configurations. See cucumber-junit-platform docs.
Solution 2:[2]
I have been looking into JUnit5 and Cucumber 7.0 the past few days, I am only adding to your own answer.. documentation is scarce, this link has been a bless and docs
you dont have to use @IncludeEngines
also notice how packages are referenced
@Suite
@SelectClasspathResource("com/rmdaw/cucumber/features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.rmdaw.repository")
last thing you can place configuration into test/java/resources/junit-platform.properties inside you can have something like this:
cucumber.publish.quiet=true
cucumber.glue=com.rmdaw.cucumber
cucumber.plugin=pretty,\
html:target/SystemTestReports/report.html,\
json:target/SystemTestReports/report.json,\
junit:target/SystemTestReports/junit.xml\
Solution 3:[3]
It looks like @Suite
from junit-platform-engine with proper engine should be used instead of cucumber annotations.
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
public class RunCucumberTest {
}
Kudos to @spmason answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | RMDaw |
Solution 3 | makozaki |