package zwh.junit.test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import zwh.junit.T;
public class TTest {
@BeforeClass
public static void beforeClass() {
System.out.println("beforeClass");
}
@AfterClass
public static void afterClass() {
System.out.println("afterClass");
}
@Before
public void before() {
System.out.println("before");
}
@After
public void after() {
System.out.println("after");
}
@Test
public void testAdd() {
int z=new T().add(5,3);
/*assertEquals(8,z);
assertTrue(z>3);
assertTrue("z too small",z>10);*/
assertThat(z,is(8));
}
// @Ignore
@Test(expected=java.lang.ArithmeticException.class,timeout=100)
public void testDivide(){
// int z=new T().divide(8,2);
int z=new T().divide(8,0);
assertThat(z,is(4));
}
}
转载于:https://my.oschina.net/zhongwenhao/blog/136575