如何使测试用例在Junit中失败?

如何使测试用例在Junit中失败?,junit,cucumber-jvm,Junit,Cucumber Jvm,当我在脚本中使用fail()[Junit]时,脚本将停止运行并跳过接下来的步骤 In TestNG, We can do that using "org.testng.Assert.fail("");" . 我的要求是继续运行下一个场景,即使我以前的案例失败了 请帮助我。您需要使用软关联。像这样的 public static void verifyFalse(boolean condition) { try { assertFalse(condition); } ca

当我在脚本中使用fail()[Junit]时,脚本将停止运行并跳过接下来的步骤

 In TestNG, We can do that using "org.testng.Assert.fail("");" .
我的要求是继续运行下一个场景,即使我以前的案例失败了


请帮助我。

您需要使用软关联。像这样的

public static void verifyFalse(boolean condition) {
    try {
        assertFalse(condition);
} catch(Throwable e) {
        e.printStackTrace();
        throw new YourException("your message");
}
JUnit具有软断言的功能

公共类ATest{
@统治
public final ErrorCollector=新ErrorCollector();
@试验
公开无效测试(){
//做点什么
收集器.addError(新的可丢弃(“出错”);
//做其他事情
}
}