开发者

Does JUnit 3 have something analogous to @BeforeClass? [duplicate]

开发者 https://www.devze.com 2023-01-03 07:46 出处:网络
This question already has answers here: Class teardown in junit 3? (2 answers) Closed 6 years ago开发者_开发知识库.
This question already has answers here: Class teardown in junit 3? (2 answers) Closed 6 years ago开发者_开发知识库.

I'm forced to use JUnit 3 for a particular test suite. I understand setUp() and tearDown() serve the function of @Before and @After, but is there an analogue of @BeforeClass and @AfterClass for things that should happen once before the tests start, and once after all tests are run?


OK, I should have searched SO better.

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 ");
    }
  };
}


No, this is a new feature in JUnit4.

0

精彩评论

暂无评论...
验证码 换一张
取 消