【问题标题】:What is TestSuite?什么是测试套件?
【发布时间】:2011-11-07 04:38:39
【问题描述】:

我对 Java 和 JUnit 测试比较陌生。 我非常清楚 Test 类的 ui 是什么,但 TestSuite 类让我感到困惑。 谁能解释一下TestSuite 是干什么用的?

【问题讨论】:

    标签: java junit test-suite


    【解决方案1】:

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

    示例来自我在 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());
        }
    }
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

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

        【讨论】:

          猜你喜欢
          • 2012-05-16
          • 2011-07-15
          • 2016-08-22
          • 1970-01-01
          • 1970-01-01
          • 2013-01-01
          • 1970-01-01
          • 2023-03-06
          • 1970-01-01
          相关资源
          最近更新 更多