I'm using cobertura and I am confused about the meaning assigned to the colors in the report. I checked the cobertura website, as well as their FAQ and github page, and searched old stack overflow questions, but I could not find an explanation of how cobertura highlights lines.
First let me say that the report appears to be different between eclipse and in firefox. In eclipse it is highlighting entire lines green, yellow, or orange. When shown in firefox, it's different. There is a line number, then a second column that holds an integer, then the source line. I am seeing places where the line number is highlighted green, and the rest of the line is red. I also noticed that cobertura never highlights the actual source line as green, it is only highlighting the first two columns green for some reason.
So let me guess as to the meaning of this (I am not saying this is right, this is my guess):
- first column is green if there was a unit test that reached the test method containing that line.
- second column is the number of unit test methods that reached that line
- second column, and source line, will be highlighted red if ALL of the unit tests that reached that line failed, or if no unit test reached that line.
First question, is the above correct? If not then please let me know what's right.
My second question is this: I have a test class that is expected to throw an exception, it is annotated @Test(expected = IllegalArgumentException.class). The test method passes but cobertura highlights all of the lines in that class as red. Why does cobertura highlight this line red if the test passed? Is there a way I can change this behaviour?
Third and last question: if two test methods both reach a line of code, and one of those test methods fails, will the line of code be highlighted red? green? or something else?