自分の2番目のjunitの例
1641 ワード
package com.xinnuo.daos;
/**
* @author bimingwei
* @ :
*/
public class Math {
public static int divide(int x,int y) {
try{ return x/y; }
catch (Exception e) {
// TODO: handle exception
System.out.println(" ");
}
return x/y;
}
public static int multiple(int x,int y) {
return x*y;
}
}
package com.xinnuo.daos;
import org.junit.After;
import org.junit.Ignore;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import static org.junit.Assert.*;
import org.junit.Test;
public class MathTest {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test// (expected=ArithmeticException.class) , test
public void testDivide() {
assertEquals(3,Math.divide(9,3));
assertEquals(3,Math.divide(10,3));
Math.divide(10,0); // 0,
}
@Ignore(" ")
@Test
public void testMultiple() {
fail("Not yet implemented");
}
}