I am not getting to the 100% code covered and would like to. Unless I see the 100% green I wonder what I forget to test and go hunting only to find out silly things based on the tool and not my test are keeping me from it. Then later I forget and have to rinse/repeat.
While all paths are covered in testThrow because of the exception it is not counted as run.
Is there a way to re-write it so it is seen as covered towards that elusive 100% green.
public class Dummy {
public void testThrow() throws Exception {
throwException(); // This line is red and is seen as not covered.
}
private void throwException() throws Exception {
throw new Exception();
}
}
public class DummyTest() {
@Test
public void testThrow() throws Exception {
new Dummy().testThrow();
}
}
I added @Test(expected=Exception.class) but the line is still red.
I also tried:
public void testThrow() throws Exception {
try {
throwException(); // This line is STILL red
}
catch(Exception e) {
throw e; // This line becomes green (as expected)
}
} // This line is now also red
You can find the same thing in EclEmma documentation: