Further Work - Code Coverage Analysis

 

Focus on the Test by Test feature you may have noticed with the other runtime analysis features.

  1. Select the menu item Code Coverage->Test by Test

  2. Open the Tests node at the top of the Report Window, then select the node referencing the source code file ItemList.cpp

  3. If necessary, select the Source tab of the Code Coverage viewer

Notice how some of the viewable code for the source file ItemList.cpp is green - that is, covered? What will happen if your manual interaction with the UMTS base station is cleared from the Tests list?

  1. In the Report Window, clear the checkbox next to the node labeled Test #1 [today's date]

The code, as should be expected, is now red. No tests, no coverage.

One great advantage of this Test by Test functionality in the code coverage feature is that is allows you to determine whether any given manual or automated test has contributed additional code coverage. Just view the Root node on the Rates tab of the code coverage viewer and then toggle your tests. Do the coverage rates for the Root node improve? If not, then the test you've just deselected is unnecessary and in all likelihood need not be run. (One could claim that this apparently unnecessary test supplies unique data elements that should be preserved, even if no new coverage is achieved. If that's the case, then perhaps the original test that achieved the established code coverage level should be enhanced to include these additional data points.)

Another nice capability of the Test by Test feature for code coverage analysis is that it enables you to determine which tests forced execution of a particular line of source code. This feature, only available when Test by Test is toggled on, is called Cross Reference and can be accessed via the right-click menu when viewing source code in the code coverage viewer. (Alternatively, you can access this feature by selecting the menu item Coverage->Cross Reference.)

  1. In the Report Window, reselect the checkbox next to the node called Test #1 [today's date]

  2. With your mouse anywhere within the Code Coverage Viewer's Source window, right-click-hold and select CrossRef

  3. Click any green or orange line of code

Notice how a box appears indicating Test #1? This is because Test #1 forced execution of the particular green or orange line of code you selected. This should be no surprise - you have only interacted with the UMTS base station once, so the only possible contributor to coverage must be Test #1. (Red lines of code haven't been covered, so it makes no sense to use the Cross Reference function with them.) This feature becomes particularly useful when you want to improve coverage for a particular section of code, and you wish to determine which tests already stimulate that area. This simplifies your effort for test reuse. We'll see more of this function in the tutorial chapter devoted to improving the issues uncovered by the runtime analysis components of Test RealTimePurifyPlus RealTimePurifyPlus for Linux.

  1. Right-click-hold and clear CrossRef

Recap