什么是TestSuite?

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

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

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

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

这里有一些很好的定义: http : //xunitpatterns.com/Testcase%20Class.html