如果特定测试失败,则停止 JUnit 套件 [英] Stopping JUnit suite if particular test fails

查看:31
本文介绍了如果特定测试失败,则停止 JUnit 套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 JUnit 测试套件的形式:

I have a JUnit test suite in the form:

@RunWith(Suite.class)
@Suite.SuiteClasses( { xx.class, yy.cass })

public class AllTests {

public static Test suite() {
    TestSuite suite = new TestSuite(AllTests.class.getName());
    //$JUnit-BEGIN$

    //$JUnit-END$
    return suite;
}
}

然后像这样调用普通测试:

This then calls vanilla tests like this:

public class xxx {

@Test
public void test () throws {
    ...

我有一种情况,如果第一次测试出现错误或失败,我想停止其余测试套件的运行.但是其他的错误/失败是可以的,套件应该完成尽可能多的其他测试.基本上,第一个测试失败表明运行其余测试是不安全的.

I have a situation where I'd like to stop the rest of the test suite running if there's an error or fail in the first test. But errors / fails in the others are ok and the suite should complete as many other tests as it can. Basically the first test failing would indicate it isn't safe to run the rest.

这可能吗?

推荐答案

调用 System.exit() 有什么问题?

这篇关于如果特定测试失败,则停止 JUnit 套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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