junit

来源:互联网 发布:wemall java版 编辑:程序博客网 时间:2024/05/29 19:40
Junit4
 

1.jUnit是一套基于测试驱动开发的测试框架。

2.编码规范


3.测试失败的两种情况




4.Junit的运行流程和Junit的常用注解


Afterclass和beforeclass要用static修饰

public class AddTest {

     @Test

     public void testAdd() {

          assertEquals(3, new Add().add(1,2));

     }

     @Test

     public void testjian() {

          assertEquals(1, new Add().jian(2,1));

     }

     @BeforeClass

     public static void BeforeClass() throws Exception{

          System.out.println("BeforeClass");

     }

     @AfterClass

     public static void AfterClass() throws Exception{

          System.out.println("AfterClass");

     }

     @After

     public void After() throws Exception{

          System.out.println("After");

     }

     @Before

     public void Before() throws Exception{

          System.out.println("Before");

     }

}

 

5.Junit测试套件的使用

 


6.junit4的参数化设置


0 0
原创粉丝点击