I need to implement the Division by Zero operation in a method such that (1) every test suite that achieves 100% path coverage reveals the fault and (2) it is possible to create a test suite that achieves 100% branch coverage and does not reveal the fault.
As division by zero is very simple operation,I would like to know the implementation of this method such that these two requirements can be met.Currently, I am not able to do it because my branch and path coverage test cases both reveals a fault(ArithmeticException) and are same.
This is my current code but it is wrong.
void method1(int m, int n)
int p = m / n;
if (n != 0) {
System.out.println("Print some value");
}
if (n == 0) {
System.out.println("Infinity");
}
return p;
Thanks