junit基础学习之-junit3和4的区别(4)

junit3junit4的使用区别如下

1.在JUnit3中需要继承TestCase类,但在JUnit4中已经不需要继承TestCase

2.在JUnit3中需要覆盖TestCase中的setUp和tearDown方法,其中setUp方法会在测试执行前被调用以完成初始化工作,而tearDown方法则在结束测试结果时被调用,用于释放测试使用中的资源,而在JUnit4中,只需要在方法前加上@Before,@After 

3.在JUnit3中对某个方法进行测试时,测试方法的命令是固定的,例如对addBook这个方法进行测试,需要编写名字为testAddBook的测试方法,而在JUnit4中没有方法命令的约束,在方法的前面加上@Test,这就代表这个方法是测试用例中的测试方法

4.新的断言assertThat 

5. @BeforeClass 和 @AfterClass 。在JUnit3,如果所有的test case仅调用一次setUp()和tearDown()需要使用TestSetup类

6.测试异常处理@Test(expected = DataFormatException.class)

7.设置超时@Test(timeout = 1000)

8.忽略测试@Ignore

9.集成测试

 

posted @ 2015-08-15 21:38  小小小的程序猿  阅读(232)  评论(0编辑  收藏  举报
window.onload = function(){ $("#live2dcanvas").attr("style","position: fixed; opacity: 0.7; left: 70px; bottom: 0px; z-index: 1; pointer-events: none;") }