2010-06-11 90 views
24

我不得不爲特定的測試套件使用JUnit 3。據我所知,setUp()tearDown()服務於@Before@After的功能,但在測試開始之前應該發生一次事件並且在所有測試運行之後,有沒有類似@BeforeClass@AfterClassJUnit 3是否有類似於@BeforeClass的東西?

+1

@Basilevs肯定的,但這個問題網上搜尋以及 – 2015-01-11 19:15:37

回答

18

好的,我應該搜索得更好。

Class teardown in junit 3?

public static Test suite() { 
    return new TestSetup(new TestSuite(YourTestClass.class)) { 

    protected void setUp() throws Exception { 
     System.out.println(" Global setUp "); 
    } 
    protected void tearDown() throws Exception { 
     System.out.println(" Global tearDown "); 
    } 
    }; 
} 
-4

不,這是JUnit4中的一項新功能。

相關問題