In cucumber-junit
library I use @CucumberOptions
to define feature files location:
package com.mycompany.cucumber;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = ...,
features = "classpath:.", // my java step definitions are in package com.mycompany.cucumber
// but feature files directly in test resources
// resources/is_it_friday_yet.feature
tags = ...,
glue = ...
)
public class CucumberRunner {
}
I'm running my tests with custom gradle task cucumberTest
cucumberTest {
useJUnitPlatform()
}
After migrating to cucumber-junit-platform-engine
@CucumberOptions
are no longer supported.
package com.mycompany.cucumber;
import io.cucumber.junit.platform.engine.Cucumber;
@Cucumber
public class CucumberRunner {
}
I can make it work with replacing plugin
, tags
, glue
options with properties cucumber.filter.tags
, cucumber.glue
, cucumber.plugin
.
What about features
property? It works fine if I change feature files location to match package name i.e. resources/com/mycompany/cucumber/is_it_friday_yet.feature
. Still this is a simple case and I have many more test packages which are not placed in the same locations as source code and I cannot move them.
In cucumber-jvm v7 the @Cucumber
annotation is deprecated and you're encouraged to use the regular @Suite
annotation. This means you can also use annotations like @SelectClasspathResource
to change the location of your feature files. This works for me:
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.mycompany.cucumber")
public class CucumberIT {
}
It picks up all my .feature files under the features/
dir in my resources folder (classpath)
Docs: https://github.com/cucumber/cucumber-jvm/tree/main/junit-platform-engine#suites-with-different-configurations
There are various other @Select*
annotations supported by junit-platform, I assume those work as well (though they're marked as experimental so subject to change): https://junit.org/junit5/docs/current/user-guide/#api-evolution-experimental-apis
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With