有人可以建议我一个解决方案,为什么当我使用命令mvn test
运行测试来运行位于ExampleRunnerTest
的黄瓜转轮类\src\test\java
时,它运行但是maven build并没有。认识到它。就像我说测试运行会做它应该做的但是构建仍然失败。
1场景(←[32m1通过←[0m]
6步(←[32m6通过←[0m]
1m36.764s
测试运行:0,失败:0,错误:0,跳过:0,已过去时间:98.777秒 - 在BasicTest中
结果:
测试运行:0,失败:0,错误:0,跳过:0
[INFO] -------------------------------------------- ----------------------------
[INFO]建立失败
[INFO] ----------------------------------------------- -------------------------
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/main/java/cucumber/feature/Basic.feature", glue = "cucumber/stepDefinition",
format = {"pretty", "html:target/cucumber", "json:target/cucumber-report.json"})
public class BasicTest {
}
答案 0 :(得分:2)
当我在我的selenium项目中遇到这个问题时,我意识到我也在使用junit和testng。我从pom.xml中删除了testng代码和依赖项。这样我只留下了我的项目中的junit。然后一切都像魅力一样,mvn测试结果显示正确的数字。
答案 1 :(得分:2)
副本-
Rai Gupta is right.
The dependency was an issue for me also.
I saw too many "Append your runner class with Test, move the runner class into TEST folder" etc.
但你只是在破坏整个设计,它会以不同设计的框架结束。
JUnit and SureFire plugin need to be aligned. I used
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
AND
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
However, this came in with a parallel execution problem. I did not need it, removed. But you can try different versions of the above dependency.
最后,这对我有用:Tests not running through Maven?
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.2</version>
</dependency>
答案 2 :(得分:0)