Java 什么是测试套件?
我对Java和JUnit测试都比较陌生。 对我来说,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
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());
}
}
它基本上是一组您(或某人)定义一次的测试,只需单击一个按钮即可运行。测试将自动运行并“标记”,如果任何测试失败,将通知您详细信息。这里有一些很好的定义: