开发者

manage thread with junit4

开发者 https://www.devze.com 2023-01-16 05:10 出处:网络
With Junit4, I tried to write a test (.class) that contains 3 @test and need to open the app in each test.

With Junit4, I tried to write a test (.class) that contains 3 @test and need to open the app in each test.

So in the function init that start the app and close it:

@BeforeClass
public static void setupOnce() {
    final Thread thr开发者_StackOverflow中文版ead = new Thread() {
        public void run() {
            //start the appli in the main
            thread.start();
        }
    }
}

@AfterClass
public static void CloseAppli() {
    closeAppli();
}

In my testClass: TestButtons.java I want to start the appli in each @test which is not possible...

Any idea?


It seems what you're looking for is the @After method. That's called after every individual test. @AfterClass is only called once at the ending of ALL the tests.

http://junit.sourceforge.net/javadoc/org/junit/After.html

0

精彩评论

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