Test invocation: how to do set up common to all test suites

前端 未结 3 1593
梦毁少年i
梦毁少年i 2021-01-12 19:30

Is there a way to know in a JUnit 4 test Class, if the Class was initiated by a Test-Suite ? I have global things that I want to run before all tests (regarding in-memory DB

3条回答
  •  忘掉有多难
    2021-01-12 20:17

    You could place some @BeforeClass code in each test suite, which delegates to an auxiliary class that does the common set up. The auxiliary class could have a static boolean that records whether the set up has already been done. If it has already been done, the auxiliary class would do nothing.

提交回复
热议问题