2010-06-11 88 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中的一项新功能。

相关问题