我想写两个测试用例,无论是积极的场景还是消极的场景。
我的示例代码是, /**
*
*/
public void testgetAsnAccuracyInstanceType() throws Exception
{
String METHOD_NAME = "testgetAsnAccuracyInstanceType";
log.entering(CLASS_NAME, METHOD_NAME);
//Rating Element "1" ASN Accuracy
populateForTestMethodValues("1");
populateWeekOfList();
List<WeeklyDeliveryInstanceTypeQO> asnAccuracyInstanceTypeList = weeklyDlvyInstancesDashboardReportForm.getAsnAccuracyInstanceType();
assertTrue("testgetASNAccuracyRatingElement is Not Empty: ", asnAccuracyInstanceTypeList.size() > 0);
log.exiting(CLASS_NAME, METHOD_NAME);
}
这个怎么样?
// use input data you expect results for
assertFalse("testgetASNAccuracyRatingElement is empty",
asnAccuracyInstanceTypeList.isEmpty());
断言否定情况:
// use input data you don't expect results for
assertTrue("testgetASNAccuracyRatingElement is not empty",
asnAccuracyInstanceTypeList.isEmpty());
这一行
assertTrue("testgetASNAccuracyRatingElement is Not Empty: ",
asnAccuracyInstanceTypeList.size() > 0);
严格等价于:
assertFalse("testgetASNAccuracyRatingElement is Not Empty: ",
asnAccuracyInstanceTypeList.isEmpty());
(如果你问的是这个)
输入/测试数据决定测试用例是正用例还是负用例。
所以只有两个测试方法(一个用于阳性,另一个用于阴性),并分别使用阳性和阴性数据调用。