使用Junit4,我尝试编写一个包含3 @test的测试(.class),并且在每次测试中都需要打开应用程序。
因此,在启动和关闭应用程序的函数init中:
@BeforeClass
public static void setupOnce() {
final Thread thread = new Thread() {
public void run() {
//start the appli in the main
thread.start();
}
}
}
@AfterClass
public static void CloseAppli() {
closeAppli();
}在我的测试:TestButtons.java中,我想在每个@testClass中启动应用程序,这是不可能的……
有什么想法吗?
发布于 2013-01-11 07:14:33
看起来你要找的是@After方法。这是在每次单独测试之后调用的。@AfterClass仅在所有测试结束时调用一次。
http://junit.sourceforge.net/javadoc/org/junit/After.html
https://stackoverflow.com/questions/3727872
复制相似问题