You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code counts 1 branch missed per case statement.
String name;
...
switch (name)
{
case "1": return(1);
case "2": return(2);
...
default: return(-1);
}
I guess it is how switch on String is implemented. I assume javac compiles the switch by using hashcodes. If so, then each case has to test for string equality before executing the case. This would create a branch for each case and hence for code coverage the branch will be counted as missed.
There isn't anything the engineer should do to eliminate this missed branch. Jacoco should recognize that the branch is due to switch on String and simply ignore the branch in each case.
The text was updated successfully, but these errors were encountered:
The following code counts 1 branch missed per case statement.
String name;
...
switch (name)
{
case "1": return(1);
case "2": return(2);
...
default: return(-1);
}
I guess it is how switch on String is implemented. I assume javac compiles the switch by using hashcodes. If so, then each case has to test for string equality before executing the case. This would create a branch for each case and hence for code coverage the branch will be counted as missed.
There isn't anything the engineer should do to eliminate this missed branch. Jacoco should recognize that the branch is due to switch on String and simply ignore the branch in each case.
The text was updated successfully, but these errors were encountered: