您的位置:首页 > 其它

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");

}

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: