Junit
来源:互联网 发布:专业看盘软件 编辑:程序博客网 时间:2024/04/28 03:55
Junit是一个java语言的单元测试框架
Junit测试是程序员测试,即所谓白盒测试,因为程序员知道被测试的软件如何(How)完成功能和完成什么样(What)的功能。Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试了。
Junit中的部分注解
A、@Before 注解:与junit3.x中的setUp()方法功能一样,在每个测试方法之前执行;
B、@After 注解:与junit3.x中的tearDown()方法功能一样,在每个测试方法之后执行;
C、@BeforeClass 注解:在所有方法执行之前执行;
D、@AfterClass 注解:在所有方法执行之后执行;
简单的测试
import static org.junit.Assert.*;import org.junit.After;import org.junit.Before;import org.junit.Test;public class Demo2 {@Beforepublic void setUp() throws Exception {System.out.println("setUp()");}@Testpublic void test1() {System.out.println("test1()");}@Testpublic void test2() {System.out.println("test2()");}@Afterpublic void tearDown() throws Exception {System.out.println("tearDwon");}}
import static org.junit.Assert.*;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;public class Demo3 {@BeforeClasspublic static void setUpBeforeClass() throws Exception {System.out.println("setUpBeforeClass()");}@AfterClasspublic static void tearDownAfterClass() throws Exception {System.out.println("tearDownAfterCLass()");}@Testpublic void test1() {System.out.println("Test1()");}@Testpublic void test2() {System.out.println("Test2()");}}
0 0
- JUNIT
- junit
- Junit
- JUnit
- JUnit
- JUnit
- JUNIT
- junit
- Junit
- JUnit
- Junit
- JUnit
- Junit
- Junit
- JUnit
- junit
- junit
- JUnit
- 初步了解Linux内核 (2)
- Android 仿照IOS的分段控件SegmentContro(自定义控件 + 事件监听 + 背景选择器)
- UIWebView简单使用
- Error connecting to MySQL server
- C#调用C++dll文件 运行提示找不到函数的入口点
- Junit
- springMVC和struts2(ssh)区别
- 国内包裹资费计算
- c# VS2008中如何修改winfrom控件的可访问性
- leetcode 148 sortList
- jquery表单提交到struts2中文乱码
- Google Protocol Buffers浅析(一)
- python--杂
- VS2010 无法命中断点