否"测试运行:0,失败:0,错误:0,跳过:0,"即使是黄瓜测试也是使用" mvn test"命令

时间:2015-06-29 13:46:21

标签: java maven unit-testing cucumber pom.xml

有人可以建议我一个解决方案,为什么当我使用命令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 {
}

3 个答案:

答案 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)

这就是我为它工作而做的事情

  1. 像 user = BlondCode 说从你的 pom.xml 文件中删除或评论 TestNG 依赖项。

  2. 将 JUnit 老式引擎依赖添加到 pom.xml

  3. 添加一个资源文件夹,您将在其中存储您的功能和步骤定义包,例如= \src\test\java\resources\feature 和 \src\test\java\resources\step 定义

  4. 您的运行包仍保留在 \src\test\java 文件夹中

  5. 最后但并非最不重要的一点是将以下配置添加到万无一失的插入中。见下图

enter image description here

相关问题