1700453207
1700453208
public class FooTest{
1700453209
1700453210
//构建测试对象
1700453211
1700453212
private Foo foo=new Foo();
1700453213
1700453214
//正常测试场景
1700453215
1700453216
@Test
1700453217
1700453218
public void testDividNormal(){
1700453219
1700453220
//断言100除以10的结果为10
1700453221
1700453222
assertEquals(10,foo.divid(100,10));
1700453223
1700453224
}
1700453225
1700453226
//边界测试场景
1700453227
1700453228
@Test
1700453229
1700453230
public void testDividBroader(){
1700453231
1700453232
//断言最大值除以最小值结果为0
1700453233
1700453234
assertEquals(0,foo.divid(Integer.MAX_VALUE, Integer.MIN_VALUE));
1700453235
1700453236
//断言最小值除以最大值结果为-1
1700453237
1700453238
assertEquals(-1,foo.divid(Integer.MIN_VALUE, Integer.MAX_VALUE));
1700453239
1700453240
}
1700453241
1700453242
//异常测试场景
1700453243
1700453244
@Test(expected=ArithmeticException.class)
1700453245
1700453246
public void testDividException(){
1700453247
1700453248
//断言除数为0时抛出ArithmeticException
1700453249
1700453250
foo.divid(100,0);
1700453251
1700453252
//断言不会执行到这里
1700453253
1700453254
fail();
1700453255
1700453256
}
[
上一页 ]
[ :1.700453207e+09 ]
[
下一页 ]