I'm on "Jacoco 0.8.0". I've got a switch statement with tests for all cases. Jacoco flags the throw and break in each case within the switch statement. The default case and break are unmarked. Why would it be flagging these?
I've looked around, and found posts like this that say previous versions had no filter for switch statements: Why is JaCoCo not covering my String switch statements?
But I'm running 0.8.0 which is after this fix, and the issue is slightly different.
MRE:
public class MyClass{
public void myMethod(String let) {
switch (let) {
case "A":
throw new Exception();
break;
default:
break;
}
}
}
Tests for each:
@Test(expected = Exception.class)
public void testMyMethodA() {
MyClass class = new MyClass();
class.myMethod("A");
}
@Test(expected = Exception.class)
public void testMyMethodDefault() {
MyClass class = new MyClass();
class.myMethod("Z");
}
Example of Flags:
public class MyClass{
public void myMethod(String let) {
[YELLOW] switch (let) {
case "A":
[RED] throw new Exception();
[RED] break;
default:
break;
}
}
}
Jacoco flags the throw statements and the breaks as untested. It flags the switch as partially tested. I expected these to be covered.