什么是TestSuite? [英] What is TestSuite?

查看:197
本文介绍了什么是TestSuite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手,也是JUnit测试的新手。
我绝对清楚测试类是什么,但 TestSuite 类让我感到困惑。
有人能解释一下 TestSuite 用于什么?

I am relatively new to Java and new to JUnit testing. It's absolutely clear to me what the Test class uis, but the TestSuite class confuses me. Can someone explain me what TestSuite is for?

推荐答案

它是一系列测试。它允许您将这样的集合作为一个组运行。

Its a collection of tests. It allows you to run such a collection as a group.

我在google找到的第一个链接示例。

Example from the first link I found with google.

import junit.framework.Test;
import junit.framework.TestSuite;

public class EcommerceTestSuite {

    public static Test suite() {

        TestSuite suite = new TestSuite();

        //
        // The ShoppingCartTest we created above.
        //
        suite.addTestSuite(ShoppingCartTest.class);

        //
        // Another example test suite of tests.
        // 
        suite.addTest(CreditCardTestSuite.suite());

        //
        // Add more tests here
        //

        return suite;
    }

    /**
     * Runs the test suite using the textual runner.
     */
    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }
}

这篇关于什么是TestSuite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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