黄瓜方案失败时,MVN测试不会失败 [英] mvn test doesn't fail when Cucumber scenario fails

查看:79
本文介绍了黄瓜方案失败时,MVN测试不会失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 RunCucumberTest 类,如JUnit部分此处,并且从IntelliJ中的装订线图标运行时,黄瓜方案将失败.

但是,为什么 mvn测试构建成功?

  [警告]测试运行:482,失败:0,错误:0,跳过:12[信息][INFO] ------------------------------------------------------------------------[INFO]建立成功[INFO] ------------------------------------------------------------------------[INFO]总时间:02:10分钟[INFO]完成于:2021-01-04T15:54:51-05:00[INFO] ------------------------------------------------------------------------ 

我在日志中看到方案失败:

  ............................................F - ...................................................................................................失败的情况:com/rose/sample.feature:23#功能名称26个场景(1个失败,25个通过)132个步骤(1个失败,2个跳过,129个通过)0分0.596秒org.junit.ComparisonFailure:预期:< x>但是是:< y> 

解决方案

进一步搜索之后,我终于发现问题是由于在使用 https://stackoverflow.com/a/19928639/4179032 ./p>

I have a RunCucumberTest class as described in the JUnit section here and a Cucumber scenario that fails when run from the gutter icon in IntelliJ.

However, why does mvn test build successfully?

[WARNING] Tests run: 482, Failures: 0, Errors: 0, Skipped: 12
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:10 min
[INFO] Finished at: 2021-01-04T15:54:51-05:00
[INFO] ------------------------------------------------------------------------

I can see in the log that the scenario failed:

............................................F--.....................................................................................
Failed scenarios:
com/rose/sample.feature:23 # Feature name
26 Scenarios (1 failed, 25 passed)
132 Steps (1 failed, 2 skipped, 129 passed)
0m0.596s
org.junit.ComparisonFailure: expected:<x> but was:<y>

解决方案

After further Googling, I finally figured out the problem was due to having both JUnit and TestNG as dependencies in my project while using the JUnit Cucumber runner. Since I couldn't remove the JUnit and TestNG dependencies as they were inherited from a parent POM, I changed the Cucumber runner to use TestNG instead and it worked.


I later found another, simpler solution: https://stackoverflow.com/a/19928639/4179032.

这篇关于黄瓜方案失败时,MVN测试不会失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆