I have this if-else statement and I want to write a J unit test that will test each individual line to see is correct. Any ideas?
public class Testings {
public static int computeValue(int x, int y, int z) {
int value = 0;
if ( x == y )
value = x + 1;
else if (( x > y) && ( z == 0))
value = y + 2;
else
value = z;
return value;
}
}
Test your method with the values that cover all cases:
Example:
Also, you should have one assert per test method so you can give it a proper name: