我的一些java项目中有一些cucumber java测试套件。他们用JUnit 4的跑步者
@RunWith
注释和黄瓜赛跑者。
我刚从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 { }
胶水看起来是这样的(这是一个JUnit4断言):
@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中运行时,这些才被视为“跳过”。