I want to write the both test cases whether positive scenario and negative scenario.
My sample code is,
/**
*
*/
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);
}
How about this?
To assert it works:
// use input data you expect results for
assertFalse("testgetASNAccuracyRatingElement is empty",
asnAccuracyInstanceTypeList.isEmpty());
To assert the negative case:
// use input data you don't expect results for
assertTrue("testgetASNAccuracyRatingElement is not empty",
asnAccuracyInstanceTypeList.isEmpty());