junit4的测试方法的执行顺序
2016-05-12 22:28
417 查看
package cn.xxx.test;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
public class TestJunit4 {
@Test(expected = ArithmeticException.class)
public void testExpected() {
System.out.println("@Test(expected = Exception.class)");
throw new ArithmeticException();
}
@Ignore
@Test
public void testIgnore() {
System.out.println("@Ignore");
}
@Test
public void test() {
System.out.println("@Test");
assertEquals(5 + 5, 10);
}
@Test(timeout = 50)
public void testTimeout() {
System.out.println("@Test(timeout = 50)");
assertEquals(5 + 5, 10);
}
@After
public void after() {
System.out.println("@After");
}
@Before
public void before() {
System.out.println("@Before");
}
@AfterClass
public static void afterClass() {
System.out.println("@AfterClass");
}
@BeforeClass
public static void beforeClass() {
System.out.println("@BeforeClass");
}
}
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
public class TestJunit4 {
@Test(expected = ArithmeticException.class)
public void testExpected() {
System.out.println("@Test(expected = Exception.class)");
throw new ArithmeticException();
}
@Ignore
@Test
public void testIgnore() {
System.out.println("@Ignore");
}
@Test
public void test() {
System.out.println("@Test");
assertEquals(5 + 5, 10);
}
@Test(timeout = 50)
public void testTimeout() {
System.out.println("@Test(timeout = 50)");
assertEquals(5 + 5, 10);
}
@After
public void after() {
System.out.println("@After");
}
@Before
public void before() {
System.out.println("@Before");
}
@AfterClass
public static void afterClass() {
System.out.println("@AfterClass");
}
@BeforeClass
public static void beforeClass() {
System.out.println("@BeforeClass");
}
}
相关文章推荐
- 学习编程的好网站
- 私有继承和组合
- 129.Longest Consecutive Sequence
- 学习练习 java 验证码练习
- js中定时器的使用
- GDB(四):gdb coredump
- js dom
- 简要分析Windows驱动加载
- 第7周 C语言程序设计(新2版) 练习1-18 删除空格制表符 (程序不能正确运行)
- 【操作系统】实验三 进程调度模拟程序
- CSS浮动的应用
- CentOS6.7安装python的virtualenv环境
- JavaWeb-servlet总结(一)
- 美丽说、蘑菇街这类网站
- VB6.0编程笔记——(1)篇外篇&目录
- 【操作系统】实验三 进程调度模拟程序
- 模板方法模式(TemplateMethod)
- 第103课:动手实战联合使用Spark Streaming、Broadcast、Accumulator实现在线黑名单过滤和计数
- haroxy hdr
- C++空类的作用一