如何使用jUnit将测试用例添加到套件中? [英] How to add test cases to a suite using jUnit?

查看:120
本文介绍了如何使用jUnit将测试用例添加到套件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个测试类,都扩展 TestCase 。每个类都包含一系列针对我的程序运行的单独测试。

I have 2 test classes, both extend TestCase. Each class contains a bunch of individual tests which run against my program.

如何在同一套件中执行这两个类(以及他们拥有的所有测试)?

How can I execute both classes (and all tests they have) as part of the same suite?

我正在使用jUnit 4.8。

I am using jUnit 4.8.

推荐答案

在jUnit4中你有这样的东西:

In jUnit4 you have something like this:

@RunWith(Suite.class)
@SuiteClasses({
    SomeTest.class,
    SomeOtherTest.class,
    ...
    })
public class AllTests {}

如果你想要Eclipse GUI套件构建器(New> JUnit Test suite),你必须添加

If you want the Eclipse GUI suite builder (New > JUnit Test suite), you have to add

public static junit.framework.Test suite() {
   return new JUnit4TestAdapter(SomeTest.class);
}

GUI测试套件构建器可识别您的测试。

to each of your test classes s.t. the GUI test suite builder recognizes your test.

这篇关于如何使用jUnit将测试用例添加到套件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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