I am doing Android Unit Test Case Execution and for Negative Test Case I should get exception, but for some API's Exception is not caught.
Please do find the example below:
public void testInsertSenderType_n() { DBSms obj = new DBSms(getContext()); obj.open(); int i =0; int a =0; boolean result = true; i=obj.GetToatlCount(); obj.insertSmsText(i+1,"Hello to testInsertSenderType_n"); a=obj.TotalcountSms("Inbox"); try { obj.insertSenderType(-100, "Richard", "Inbox", 0); } catch (Exception e) { // TODO: handle exception result = false; } assertEquals(a,obj.TotalcountSms("Inbox")); assertEquals(false,result); obj.close(); } Here in, obj.insertSenderType(-100, "Richard", "Inbox", 0); should throw an exception. But it is not thrown.
Please do guide where can I be Wrong.