C++test provides numerous metrics for code coverage: Function, Line, Statement, Block, Path, Decision, Simple Condition, and Modified Condition/Decision Coverage (MCDC). By default, only line coverage data is collected. You can easily add additional coverage data collection as needed by Change the Instrumentation mode settings in the "Run Unit Tests" Test Configuration to Full.

 

 

Reviewing code coverage results

  1. Open the coverage view, which provides an expandable view of code coverage results organized by file names associated with unit test results.
    • If the coverage view is not available, enable it by choosing Parasoft> Show View> Coverage.



  2. Double-click a line in the Coverage view to open the associated source code in the editor window. The source code highlighted in green identifies code covered; code not covered is highlighted in red. The code is synced with information in the Coverage view.



  3. You can synchronize information in the Coverage view with the Test Case Explorer, which helps you pair test cases with code marked as covered.
    1. Drag the Test Case Explorer to the project tree panel and anchor it as a tab so you can view the Test Case Explorer and Coverage tabs at the same time.



    2. Open the Coverage tab and click on the Synchronize gears button icon to sync the two views.



    3. Click on test cases in the Test Case Explorer and the Coverage view will be updated to show the corresponding percentage of code covered.



        • Note that when the Test Case Explorer and Coverage tabs are synced, the highlight colors in the code editor view will also be synced with selections in the Test Case Explorer. If we select test_fillUserRequest_1, the color coding in the editor will change to reflect lines of code covered by this test case.

  4. In the code editor, right-click on a line of code and select Parasoft> C++test> Show test case(s) for covered element. This will show which test cases specifically covered the selected line of code. Mouse over a line of code in the editor view, a popup window will show not covered or covered and a hit count.

  • No labels