开发者

write a clean junit4 tests

开发者 https://www.devze.com 2023-01-16 16:24 出处:网络
with junit test , how could I start the app开发者_Go百科lication software then close it properly and do it for each test ?

with junit test , how could I start the app开发者_Go百科lication software then close it properly and do it for each test ?

  • @test public void test1(){ // start appli //test Jtextfield //close appli }
  • @test public void test2(){ // start appli //test ComboBox //close appli }
  • @test public void test3{ // start appli //test Jbutton //close appli

}


Generally there are means of doing some action before and after test class / test method passing in junit 4 (see info about @BeforeClass and @BeforeMethod annotations, for example, here: http://junit.sourceforge.net/javadoc/org/junit/BeforeClass.html)

But application starting/stopping behavior looks closer to functionality testing, not unit testing. Probably it would be better not to start and stop whole application, but perform some application reinitialization.

Also, there's perfect functionality testing framework TestNG (http://testng.org), and it also provides means like beforeclass / beforemethod annotations.

0

精彩评论

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