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

后端 未结 5 492
暖寄归人
暖寄归人 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:51

    try using @before and creating a method which instances all objects you need if you need to clear something after ending just use @After

    something like this:

    @Before
    public void instanceMeasureList() {
        /* all what you need to execute before starting your tests
        */
    }
    
    @Test
    public void testRequest() {
        fail("Not yet implemented");
    }
    
    @Test
    public void testEpochDate() {
        fail("Not yet implemented");
    }
    @After 
    public void deleteOutputFile() {
          fail("Not yet implemented");
    }
    

提交回复
热议问题