I'm having issues getting my cucumber tests to be invoked. I'm using SpringBootTest for these and invoking them via the maven failsafe plugin. I know for a fact that the features path is correct because 1. If I run the tests directly using Intellij's runner, it runs all the tests and 2. If I run via Maven and use the wrong path Cucumber itself throws exceptions.
Please find relevant project excerpts below:
CucumberIT.java
@RunWith(Cucumber.class)
@CucumberOptions(
features = {
"src/test/resources/features/"
},
glue = {
"classpath:com.company.pkg.integration.steps"
}
)
public class CucumberIT {}
CucumberContextLoader to load the Spring Context for all features to access
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
@ContextConfiguration(initializers = ConfigInitializer.class)
public class CucumberContextLoader {
@Before // Note this is Cucumbers Before, not JUnits.
public void setUp() {
}
}
pom.xml Profile for running integration tests:
<profile>
<id>integration-test</id>
<properties>
<skip.surefire.tests>true</skip.surefire.tests>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
The output that this all gives me is:
[INFO] --- maven-failsafe-plugin:3.0.0-M4:integration-test (default) @ my-rest-service ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
Mar 02, 2020 1:19:56 PM io.cucumber.junit.Cucumber <init>
WARNING: By default Cucumber is running in --non-strict mode.
This default will change to --strict and --non-strict will be removed.
You can use --strict or @CucumberOptions(strict = true) to suppress this warning
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.971 s
[INFO] Finished at: 2020-03-02T13:19:57-05:00
[INFO] ------------------------------------------------------------------------