View Code Coverage Output

After you have enabled code coverage, as described in Enable/Disable Code Coverage, debug your code and execute all test cases to completion. Then, halt execution automatically or manually and step as needed till all code execution is complete.

To view code coverage:

  • Right-click on project name and select “Show Code Coverage Summary” or select Window>Debugging>Code Coverage.
  • To see highlight in the Editor window, you may need to click in it. Covered code will be highlighted in the window.
  • To see highlight in the Program (or Execution) Memory window, open it under Windows>Target Memory Views. Covered instructions will be highlighted in the window.
  • A summary report will be shown in the Code Coverage tab.
Figure 1: Code Coverage in MPLAB X IDE

Highlight Colors

The meaning of highlight colors in the Editor window and Program or Execution Memory window are described in the table below.

Highlight Color Highlight Name Meaning
ColorGreen_Covered.png Green Covered and Executed
ColorYellow_PartialCoverage.png Yellow Covered and Partially Executed (Editor Window Only)
ColorRed_NoCoverage.png Red Covered but not Executed
No Color No coverage information generated*

* Reasons why no coverage information would be generated include:

  • Some C constructions may not generate code for a C source line.
  • Optimizations may cause code not to be generated for a C source line.

There may be other circumstances that C source lines do not produce executable code. See the examples in Understand Code Coverage Output.

Coverage Colors

On the Code Coverage tab, the colors on the bar chart under “Coverage” have the following meanings:

Coverage Color Coverage Name Meaning
ColorGreen_Covered.png Green Total code covered and executed by test suite(s).
ColorRed_NoCoverage.png Red Total code covered by test suite(s).

For more on this tab, see Code Coverage Window.

Code Coverage Tab Buttons

Click on buttons in the left-side menu of this tab for the following functions.
GenerateReport_Icon.png Generate HTML Report. This report will show the same data presented in the Code Coverage window..
ToggleEditorHighlight_Icon.png Toggle (enable/disable) color highlighting in the Editor window.
OpenProjectProperties_Icon.png Open Project Properties to enable/disable code coverage.
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.