JUnit使用(二)
来源:互联网 发布:腾讯代理绝地求生优化 编辑:程序博客网 时间:2024/06/06 04:21
JUnit运行流程
1.@BeforeClass修饰的方法会在所有方法被调用之前运行,而且该方法是静态的(static修饰),当测试类被加载后就运行了它,在内存中只会存在一份实例,比较适合修饰配置文件.
2.@AfterClass所修饰的方法通常用来进行对资源的管理(static修饰).
3.@Before和@After在每个测试方法的前后各运行一次
测试代码:
import static org.junit.Assert.*;import java.text.Collator;import org.junit.After;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;import com.yangshunfan.JUnit.Math;public class MathTest {@AfterClasspublic static void afterClass() {System.out.println("类之前运行");}@BeforeClasspublic static void beforeClass() {System.out.println("类之后运行");}@Afterpublic void after() {System.out.println("方法之前运行");}@Beforepublic void before() {System.out.println("方法之后运行");}@Testpublic void test1(){System.out.println("这是方法1");}@Testpublic void test2(){System.out.println("这是方法2");}}
0 0
- JUnit使用(二)
- 【Junit】Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- Junit使用教程(二)
- (二)JUnit使用详解
- Java单元测试Junit(二)使用DBUnit扩展JUnit
- Eclipse中使用Junit插件测试(二)
- 在MyEclipse 2014 中使用JUnit-(二)
- junit(二)
- junit 使用
- junit使用
- solrcloud 报 HTTP Status 503
- 最新版的OpenCV中新增加的ORB特征的使用
- git detachhead在回滚代码的时候的使用
- 归并排序
- eclipse的maven项目导入第三方jar包到pom.xml的方法
- JUnit使用(二)
- PHP调试的时候遇到Warning: session_start() [function.session-
- 理解Java内存模型
- bash数据流重定向与管道
- Android 在 Eclipse 项目中使用 Leakcanary 内存泄露检测
- Java内存管理:深入Java内存区域
- Gradle 1.12用户指南翻译——第五十九章. 组织构建逻辑
- 预习数组与指针
- [Azure]Azure虚拟机扩展的介绍和使用