Java jUnit: Test suite code to run before any test classes

后端 未结 5 506
暖寄归人
暖寄归人 2020-12-31 01:33

I have a test suite class:

@RunWith(Suite.class)
@Suite.SuiteClasses({
    GameMasterTest.class,
    PlayerTest.class,
})
public class BananaTestSuite { 
         


        
5条回答
  •  粉色の甜心
    2020-12-31 01:54

    Annotate a method with @BeforeClass to make it run before all tests run in that class. Annotate a method with @Before to make it run before each test in that class.

    re. your comments, @BeforeClass works fine. Are you throwing an exception within that method ?

提交回复
热议问题