Exploring Coverage Analysis Views > Exploring the Coverage Source View > Understanding the Data in a Source View
In a Source view, your code is color-coded to highlight missed lines of code and missed conditions (requires condition data). If the snapshot contains data on conditions, you can select a condition and see details about it in the Condition Details table.
By default, the source code is color-coded to highlight missed lines of code and, if available, missed conditions:
• Missed lines, including condition statements with all outcomes missed, are red.
• Condition statements with some missed outcomes are gold.
• Code that was hit by your test case is black.
• Code for which there is no data is gray.
• Filtered out catch blocks are gray.
You can change these colors. For more information, see Customizing the Colors Used to Display Results.
Along the right margin is a navigation aid called the Coverage Bar. The length of the Coverage Bar represents all the source code in the file, not just the code currently displayed in the view. The colored stripes on the bar represent the relative size and position of missed lines of code and missed conditions (if available). You can click a stripe to navigate to that block of code. For more information, see Interacting with the Source View.
When the snapshot contains data on conditions, the Missed Conditions column displays the number of missed outcomes within the context of the total number of possible outcomes. For example, if one out of two conditions were missed, the value “1 of 2” is displayed.
To understand how JProbe determines the total number of conditions, consider the following if statement:
if(a && b && c)
JProbe calculates two possible outcomes (true and false) for each of the three subconditions for a total of six possible outcomes (2+2+2=6). Note that the calculation is not based on the combinations that these possible outcomes can generate (2x2x2 = 8).
If the condition outcomes do not match your expectations, your compiler may have made some optimizations or rearrangements when creating bytecode. For more information, see Nonintuitive Results for Conditions.
This column simply states if the line of code was missed.
When you select a condition in the source code, the Condition Detail table is populated with details about the condition coverage.
If the condition is a switch...case, the table includes the possible case values including the implicit or explicit default, and whether or not each was executed.
For non-switch conditions, the table displays the conditional opcode mnemonics from the line, and for each indicates whether execution of the condition resulted in a true or false outcome.
If you are unfamiliar with opcodes, you may want to read the following background material. Your java compiler (for example javac) compiles Java source code into instruction opcodes known as bytecode for the Java virtual machine. Conditions in the source code are translated into condition opcodes in the JVM instruction set. The condition opcodes are like a simple if statement that only ever checks a single true/false condition. A compound condition in Java source such as if (a && b) becomes multiple condition opcodes in the compiled bytecode.
For more information on how compilers generate bytecode for the JVM, refer to The Java Virtual Machine Specification published by Sun Microsystems. In particular, see the following chapters:
• Chapter 6, “The Java Virtual Machine
Instruction Set”
http://java.sun.com/docs/books/jvms/second_edition/html/Instructions.doc.html
• Chapter 7, “Compiling for the Java
Virtual Machine”
http://java.sun.com/docs/books/jvms/second_edition/html/Compiling.doc.html
JProbe Coverage uses condition opcodes to collect condition coverage data. For each condition opcode, as your program runs JProbe will track which of the two possible outcomes (true or false) have occurred and record this in the snapshot. In the Source View of the snapshot, for each line which has a conditional opcode, the Conditional Data table displays the conditional opcode mnemonics from the line, and for each indicates whether execution of the condition resulted in a true or false outcome.
Note Opcodes generated by a compiler often differ from the source code. You may see a condition in your source code that does not evaluate as you expect. For more information, see Nonintuitive Results for Conditions.
The following table lists the opcodes that may appear in the Condition Detail table: