What order are the Junit @Before/@After called?

前端 未结 6 1420
不思量自难忘°
不思量自难忘° 2020-12-07 15:27

I have an Integration Test Suite. I have a IntegrationTestBase class for all my tests to extend. This base class has a @Before (public void s

6条回答
  •  情话喂你
    2020-12-07 15:40

    You can use @BeforeClass annotation to assure that setup() is always called first. Similarly, you can use @AfterClass annotation to assure that tearDown() is always called last.

    This is usually not recommended, but it is supported.

    It's not exactly what you want - but it'll essentially keep your DB connection open the entire time your tests are running, and then close it once and for all at the end.

提交回复
热议问题