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

查看:171
本文介绍了如果特定测试失败,则停止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;
}
}

然后调用这样的vanilla测试:

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.

这可能吗?

推荐答案

调用<$有什么问题? c $ c> System.exit()?

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

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