gpt4 book ai didi

java - 如果从 Maven 运行,Cucumber 测试结果总是返回 0

转载 作者:行者123 更新时间:2023-11-30 10:19:51 29 4
gpt4 key购买 nike

编辑(2018-01-24):
由于所有评论均无效,我更新了帖子以包含当前状态并包含更多详细信息。如果谁能有新鲜感,请继续。


当运行mvn clean test时,Cucumber的测试结果总是0。当一个步骤失败时,结果总是BUILD SUCCESS。

Maven 结果:

mvn_clean_test

目录结构:

dir_struc

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 {

}

最佳答案

我找到了解决方案。

问题是由 TestNG Assert 引起的。看起来 Maven 只读取 JUnit 断言。

当我将我的 JUnit 断言切换到 TestNG 时,我能够重现您的问题。

Recreated problem

关于java - 如果从 Maven 运行,Cucumber 测试结果总是返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48399561/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com