Maven is ignoring Cucumber tests
For anyone else coming to this question that may have had the issue I was having, @P.J.Meish's answer worked for me:
"I don't know about TestNG, but when running test with JUnit (at least with Java classes), the names of the classes must end with 'Test'. So maybe you need to name your testfile accordingly."
So I renamed my test runner class to end with 'Test' and that resolved the issue of maven not running my cucumber tests.
Yup the runner or main class name should end with Test,
It seems like maven didnt find any tests. Can you share your runner class? Also, you may wanna define the scope for your testng groupid.
https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesTest.java
Edit:
I learnt something new today ... Given == gegeven!
I got the project you have running but with changes. Follow the structure for the project: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
Here are the pom changes: As @chrylis had questioned, Junit and TestNG were both present and is not needed. Delete junit Your dependencies would be something like this:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
I was not able to make the suite run with your Runner class and used TestNGCucumberRunner class for execution.
/** Create one test method that will be invoked by TestNG and invoke the
* Cucumber runner within that method.
*/
@CucumberOptions(plugin = "json:target/cucumber-report-composite.json")
public class RunCukesByCompositionTest {
@Test(groups = "examples", description = "Example of using TestNGCucumberRunner to invoke Cucumber")
public void runCukes() {
new TestNGCucumberRunner(getClass()).runCukes();
}
}