I am using the Maven (2) Cobertura plug-in to create reports on code coverage, and I have the following stub I am using in a method:
try {
System.exit(0);
} catch (final SecurityException exception) {
exception.printStackTrace();
}
System.err.println("The program never exited!");
I know that I need to log the exception, etc, but that's not the point right now...Cobertura is refusing to acknowledge that the line after the stack trace is printed is covered. That is, the line with the '}' before the System.err.println statement is not being shown as covered. Before, the ending curly brace of the method was not being shown as covered, hence the System.err statement. Any idea how I can convince cobertura's maven plugin that, since the System.err.println statement is covered, that ending brace has to have been covered?
Oh yeah, and I use a mock security manager to throw the security exception, since that's the easiest way I've found of making the test continue executing after the System.exit call.