* @author bulargy.j.bai
* @创建时间:Mar 11, 2008
* @描述:
*/
@RunWith(Parameterized.class)
public class MathTest {
int faciend;
int multiplicator;
int result;
public MathTest(int faciend, int multiplicator, int result) {
this.faciend = faciend;
this.multiplicator = multiplicator;
this.result = result;
}
/**
* @throws java.lang.Exception
*/
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
/**
* @throws java.lang.Exception
*/
@AfterClass
public static void tearDownAfterClass() throws Exception {}
/**
* Test method for {@link org.bj.util.Math#divide(int, int)}.
*/
@Test(expected=ArithmeticException.class)
public void testDivide() {
assertEquals(3,Math.divide(9,3));
assertEquals(3,Math.divide(10,3));
Math.divide(10,0);//除数不能为0,会抛出异常
}
/**
* Test method for {@link org.bj.util.Math#multiple(int, int)}.
*/
//@Ignore(\"忽略乘法测试\")
@Test
public void testMultiple() {
assertEquals(result,Math.multiple(faciend,multiplicator));
}
@Parameters
public static Collection multipleValues() {
return Arrays.asList(new Object[][] {
{3, 2, 6 },
{4, 3, 12 },
{21, 5, 105 },
文章来源于领测软件测试网 https://www.ltesting.net/