JUnit之测试方法
2015-04-28 08:01
141 查看
一、测试方法规范
JUnit测试方法必须是public、void、没有static修饰
方法以test开头,如:testRun();
在方法上加上@Test注解
二、实例代码
@Test
public void testCreateDir() {
File file = new File("d:" + File.separator + "demo");
boolean isSuccess = file.mkdir();
System.out.println(isSuccess);
//当虚拟机终止时,删除该文件或目录
if (file.exists()) {
file.deleteOnExit();
}
}三、小结
无
JUnit测试方法必须是public、void、没有static修饰
方法以test开头,如:testRun();
在方法上加上@Test注解
二、实例代码
@Test
public void testCreateDir() {
File file = new File("d:" + File.separator + "demo");
boolean isSuccess = file.mkdir();
System.out.println(isSuccess);
//当虚拟机终止时,删除该文件或目录
if (file.exists()) {
file.deleteOnExit();
}
}三、小结
无
相关文章推荐
- 【drp 11】使用Junit简单测试接口方法
- java测试一个类的方法,用junit
- junit测试中方法不运行问题所在
- Junit 实例精讲基础教程(五) JUnit套件测试,一次性运行多个测试用例(测试类的测试方法)
- 使用junit4下myeclipse环境下测试hibernate方法的心得
- 命令行下运行Junit,多个类、单个类或者单个测试方法
- 【drp 11】使用Junit简单测试接口方法
- eclipse中,junit对单个方法进行测试时空指针异常(java.lang.NullPointerException)
- 方法测试单元测试(2)--Junit简明指南
- java反射运用举例-junit测试私有方法
- myeclipse 右键测试方法run as中没有junit选项
- JUnit中测试异常抛出的方法
- junit 直接执行测试方法报错
- Junit指定运行的测试方法
- JUnit 3.8 通过反射测试私有方法
- JUnit测试时 get()方法测试失败
- [Junit] 测试方法执行顺序
- Junit参数化测试的使用方法
- 根据反射机制测试private方法(junit测试)
- JUnit测试中setup()和teardown()方法