java junit测试
2016-05-05 21:04
351 查看
如何添加junit框架:
右键项目-->build path-->add libraries --->选择junit,然后就可以使用了
测试的方法必须是空参的,没有返回值的方法。
public class TestJunit {
@Before
public void testBefore(){
System.out.println("before");
}
@After
public void testAfter(){
System.out.println("after");
}
@Test
public void test1(){
System.out.println("aa");
m1();//test的方法可以直接调用别的方法。
}
public void m1(){
System.out.println("m1 method");
}
}
@Before注解的方法会在每个@Test方法前执行,@after注解的方法会在每个@Testd方法后执行。
右键项目-->build path-->add libraries --->选择junit,然后就可以使用了
测试的方法必须是空参的,没有返回值的方法。
public class TestJunit {
@Before
public void testBefore(){
System.out.println("before");
}
@After
public void testAfter(){
System.out.println("after");
}
@Test
public void test1(){
System.out.println("aa");
m1();//test的方法可以直接调用别的方法。
}
public void m1(){
System.out.println("m1 method");
}
}
@Before注解的方法会在每个@Test方法前执行,@after注解的方法会在每个@Testd方法后执行。
相关文章推荐
- JUnit中获取测试类及方法的名称实现方法
- 程序员方面对于测试的一些实践介绍
- SpringMVC 单元测试
- Android单元测试 笔记
- 使用 Spring 进行单元测试
- junit最佳实践
- Eclipse快速上手指南之使用JUnit
- JUnit的框架设计及其使用的设计模式(精)
- 【转载】基于 JUnit 的 InstallAnywhere 安装程序图形界面自动测试框架
- myeclipse7.5配置junit
- JUnit
- junit 实例
- 10款常用Java测试工具
- Junit 入门教程一
- 在Spring 3.2中使用Flyway与TestNG配合进行单元测试
- intellij idea14 junit使用
- 控制Junit中方法的执行顺序
- 5分钟掌握JUnit要点
- 如何写出优秀的测试代码
- Junit中用到的注解