我的一些Java项目中有一些Cucumber-Java测试套件。它们是使用@RunWith
批注和Cucumber运行程序与JUnit 4运行程序一起设置的。
我刚刚从IntelliJ 18.2升级到18.3(最终版本)。在18.2中,如果断言失败,则单元测试将失败;在18.3中,失败的步骤显示为“已跳过”,并且测试通过了。我需要进行配置更改以使其正常工作吗?我正在寻找一种解决方案,该解决方案可以让我将失败和跳过都视为失败,因为这似乎是最能模仿以前行为的最可靠的解决方案。
跑步者看起来像这样:
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"junit:target/junitTests-example.xml"},
monochrome = true,
glue = {"path.to.glue"},
features = "src/test/resources/features/")
public class MyTest { }
粘合看起来像这样(这是一个JUnit 4断言):
@When("^I run a failing test$")
public void runTrivialFailureTest() {
assertNull("This test should always fail.");
}
场景定义如下:
Feature: Sample
Scenario: A trivial failing test
Given I run a failing test
Scenario: A trivial test with an undefined step
Given I run a test with an undefined step
在2018.2 IntelliJ中,该测试将被显示为失败的单元测试。在2018.3中,失败的步骤显示为已跳过,并且单元测试通过了。如果将测试类作为JUnit测试运行,或者使用Cucumber java插件运行场景,则行为没有差异。
该项目是Maven项目,从命令行在调用surefire插件时,它将测试正确显示为失败。只有在IntelliJ中运行时,它们才被视为“跳过”。