58,454
社区成员
发帖
与我相关
我的任务
分享
import static org.junit.Assert.assertNotNull;
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 TestDemo {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
System.out.println("setUpBeforeClass()");
}
@Before
public void setUp() throws Exception {
System.out.println("setUp()");
}
@Test
public void testPrint() throws Exception{
//方法名可以不以test开头,用注解方式
}
}
/*
@Test(timeout=10)
public void a(){
System.out.println("a");
}
@Test(expected = ArithmeticException.class)
public void b() throws Exception{
System.out.println("b");
throw new ArithmeticException();
}
@Ignore("Not Ready to Run")
@Test
public void c(){
System.out.println("c");
}
*/
@After
public void tearDown() throws Exception {
System.out.println("tearDown()");
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
System.out.println("tearDownAfterClass()");
}
}