编辑(2018-01-24):
由于没有任何评论有效,我已更新帖子以包含当前状态并包含更多详细信息。如果有人可以焕然一新,请继续。
运行mvn clean test
时,Cucumber的测试结果始终为0.当步骤失败时,结果始终为BUILD SUCCESS。
Maven结果:
目录结构:
的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>
转轮:
@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 {
}