Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 什么是测试套件?_Java_Junit_Test Suite - Fatal编程技术网

Java 什么是测试套件?

Java 什么是测试套件?,java,junit,test-suite,Java,Junit,Test Suite,我对Java和JUnit测试都比较陌生。 对我来说,Test类ui是什么是绝对清楚的,但是TestSuite类让我感到困惑。 有人能解释一下TestSuite的用途吗?它是一组测试。它允许您以组的形式运行这样的集合 我在谷歌上找到的第一个链接的例子 import junit.framework.Test; import junit.framework.TestSuite; public class EcommerceTestSuite { public static Test sui

我对Java和JUnit测试都比较陌生。 对我来说,
Test
类ui是什么是绝对清楚的,但是
TestSuite
类让我感到困惑。
有人能解释一下TestSuite的用途吗?

它是一组测试。它允许您以组的形式运行这样的集合

我在谷歌上找到的第一个链接的例子

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());
    }
}

它基本上是一组您(或某人)定义一次的测试,只需单击一个按钮即可运行。测试将自动运行并“标记”,如果任何测试失败,将通知您详细信息。

这里有一些很好的定义: