2012-02-08 10 views
3

私はApacheのSurefire JUnitプラグインをmavenに使用しています。JUnit3テストを繰り返す

JUnit 3.xでテストスイートを再実行したいと思います。これはJUnit 4で簡単に可能です。これは 'Parameterized'アノテーションを提供します。

私はJUnit 3.xでどのように同じことができるか知っていますか?

私の目標は、2つの異なるテストデータをすべてのテストにシードできるように、テストスイート全体を2回実行することです。

答えて

3

JUnit 3.xでは、独自のテストスイートを定義できます。あなたが追加した場合のJUnitよりyoutはJUnitのクラスへ

public static Test suite() 

方法が返される変数で定義されているすべてのメソッドを実行します。

public static Test suite() { 
    TestSuite suite = new TestSuite(YouTestClass.class); 
    suite.addTest(new TestSuite(YouTestClass.class)); //you want to run all twice 
    // suite.addTest(new YouTestClass("foo", 0); 
    // for (int i = 0; i < TEST_SETALL.length; i++) { 
    // suite.addTest(new YouTestClass("setAllTest",i)); 
    // } 

    Test setup = new TestSetup(suite) { 
     protected void setUp() throws Exception { 
      // do your one time set-up here! 
     } 

     protected void tearDown() throws Exception { 
      // do your one time tear down here! 
     } 
    }; 

    return setup; 
} 
:あなたはまた、このような何かを行うことができ

(質問に)JUnit and junit.framework.TestSuite - No runnable methodsまたはhttp://junit.org/apidocs/junit/framework/TestSuite.html上で見ることができます