Using Class Coverage

Class Coverage buttonOptimizeit Code Coverage has two ways to view results: Class Coverage and Method Coverage. By default, when you start Optimizeit Code Coverage, the Class Coverage view opens. To return to Class Coverage from Method Coverage, click the Class Coverage button on the main menu bar.

Class Coverage lists all classes and the real-time test results for each class. You can see how many lines have not been executed, and can apply filters to test only certain classes.

Class Coverage view

The Class Coverage table contains these columns:

Column Description
Class Name All the classes that will be tested with the selected filters. If a class has not yet been loaded, Not Loaded appears on that row.
Coverage % The percentage of coverage for each class.
When the classes have been compiled with line debug information (the default when you use javac) this percentage represents the number of lines of code that have been tested compared to the overall number of lines of code for that class.

If the line debug information is not available (because the classes were compiled with the -g:none option), this percentage represents the number of methods from that class that were executed compared to the total number of methods.

Tip: For more accurate test results, do not compile your application using the -g:none option.

Diff. Similar to the Coverage column, but only shows the coverage occurring since the last mark.

To sort the values in columns of the table, click on the column header.

The Filters box at the bottom allows you to select the classes that you want to view. The classes that you exclude will still be tested, but Optimizeit will not show them in the results.

Note: This is different from the filters you set before the test is run, using the Filter Editor. Those filters, contained in .oif files, select which classes are tested.

For example, to see only the classes from the com.sun.estore.inventory package, enter the following in the filter box:

com.sun.estore.inventory.*

Both the asterisk wildcard character (*) and the not character (!) are supported. It is also possible to enumerate more than one pattern using a comma (,) separator. For example, to see all classes matching EJB except those ending with Impl:

*EJB*, !*Impl

To see all tested classes, either clear the filter completely or type an asterisk (*).



Controlling the test program

The Optimizeit tool bar provides the following buttons to control the test program run:

Start Starts or resumes the test program. This control is red when the test program is running.
Pause Pauses or resumes the test program. Use this button to freeze the flow of execution to better study the interaction between different parts of the tested program.
Stop Stops testing. If you are running your test program from within the Code Coverage user interface, the program will stop and the test will end. If you are connected to a remote server, and the test program is running on the remote machine, Stop will just disconnect your Code Coverage user interface. The test program itself will keep running on the remote server.


Mark and Inspector options

Two of the tool bar icons, Mark and Inspector, have special functions in Class Coverage:

Mark Click Mark to set a mark at any time. This resets the values in the Diff. column of the Class Coverage table. If you set the mark before a specific action in your application, you can see how this action affects the testing of your classes.
Inspector Click Inspector to view the options for the Class Coverage display.

Inspector options for Class Coverage

Option Description
Show Line Coverage Adds columns displaying the number of missed lines and number of missed lines since the mark (missed line diff). The information is displayed in the form:
missed lines / total number of lines

The Missed Lines Diff column shows the number of lines of code that have not been executed since the mark.

Note: These columns display N/A (Not Applicable) if the class has been compiled without the line information, or if the row describes coverage of an interface.

Show All Accessible Classes Displays all the classes accessible from the CLASSPATH and not filtered out by the specified filters. This includes the classes not loaded in the virtual machine.
Code Coverage reports the classes not loaded by looking through the CLASSPATH. Any class found in the CLASSPATH is reported if it is not filtered out by the specified filter file. Set the java property ccoverage.classpath if you want Code Coverage to use a different path. The following commands start the testing of an application and use different paths to search for classes that are not loaded.
On Windows:
c:\ java -Xruncci:filter=<OptItDir>\filters\DefaultAllOn.oif 
    -Xbootclasspath/a:c:\Optimizeit\CCoverage\lib\oibcp.jar 
    intuitive.audit.Cover MyApp
c:\ java -Xruncci:filter=<OptItDir>\filters\DefaultAllOn.oif 
    -Xbootclasspath/a:c:\Optimizeit\CCoverage\lib\oibcp.jar 
    -Dccoverage.classpath=d:\StoreEJBs.jar;d:\classes 
    intuitive.audit.Cover MyApp

On Solaris or Linux:

$ java -Xruncci:filter=<OptItDir>/filters/DefaultAllOn.oif 
    -Xbootclasspath/a:/opt/sfw/Optimizeit/CCoverage/lib/oibcp.jar 
    -Dccoverage.classpath=/home/StoreEJBs.jar:/home/classes 
    intuitive.audit.Cover MyApp
Show Interfaces Displays the interfaces that have been loaded by the virtual machine.