Reputation: 5472
EDIT (2018-01-24):
Since none of the comments are working, I have updated the post to include the present state and include more details. If anyone can have a fresh look, please go ahead.
When running mvn clean test
, the test results for Cucumber are always 0. When a step fails, the result is always BUILD SUCCESS.
Maven Results:
Directory Structure:
pom.xml:
<project>
[...]
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Core Dependencies -->
<java.version>1.8</java.version>
<cucumber.version>1.2.5</cucumber.version>
<ngwebdriver.version>1.0</ngwebdriver.version>
<selenium.version>3.8.1</selenium.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.paulhammant/ngwebdriver -->
<dependency>
<groupId>com.paulhammant</groupId>
<artifactId>ngwebdriver</artifactId>
<version>${ngwebdriver.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<includes>
<include>**/*Runner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Runner:
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features", tags = { "~@ignore" }, glue = "stepdefs", plugin = {
"pretty", "html:target/cucumber-reports/test-report", "json:target/cucumber-reports/test-report.json",
"junit:target/cucumber-reports/test-report.xml" }, snippets = SnippetType.UNDERSCORE, monochrome = true, dryRun = false)
public class MainRunner {
}
Upvotes: 6
Views: 2047
Reputation: 3635
I found the solution.
Problems are caused by TestNG
Assert
. Looks like Maven reads only JUnit
Asserts.
When I switched my JUnit
Asserts to TestNG
I was able to recreate your issue.
Upvotes: 2