10.3.1 Code Coverage Overview
Code coverage provides visibility as to what portions of the code are being executed. To view code coverage output, an MPLAB XC C compiler that supports code coverage must be used with MPLAB X IDE. Support for code coverage begins with these versions:
- MPLAB X IDE v5.25
- MPLAB XC8 v2.10
- MPLAB XC16 v1.40
- MPLAB XC32 v2.30
In MPLAB X IDE, you can enable code coverage in the Project Properties window under a compiler category. Once enabled, debug your test code to execute it completely and then halt/pause. Select to see the percentage of covered code executed/total code covered in the Code Coverage tab window.
For more detailed coverage information, you can purchase an MPLAB Analysis Tool Suite license to activate the full code coverage features of your compiler to include:
- Editor text highlighted by colors representing coverage: green = executed, yellow = partially executed, and red = not executed.
- Program memory highlighted by colors representing coverage.
- A Code Coverage tab with a report displaying color percentages of code covered. This information may be written to an HTML Report for later viewing.