This is a Visual Studio Code extension that allows you to see your code coverage.
Does your project use tests? What about code coverage tool? When your development environment prepares coverage report, this extension will highlight your code fragments.
This extension supports several code coverage formats. Depending on the format only code lines or certain fragments can be be highlighted.
Format | Search pattern | Fragments highlighting |
---|---|---|
LCOV | coverage/lcov*.info |
No |
Istanbul | coverage/coverage-final.json |
Yes |
Cobertura | cov*.xml |
No |
Appearance depends on your code coverage format and configuration.
Istanbul file is providing fragment highlighting:
The LCOV format was used there. Only uncovered lines were highlighted. This format doesn't support fragment highlighting:
You can enable wholeLine
mode. It will look especially good when your coverage format doesn't support fragments:
Whereas extension be able to find coverage file, it will add icon to your status bar. There will be average code coverage percentage. Click on eye-icon will switch coverage displaying.
You can adjust some of the configuration options.
The extension will search coverage report files at start. Also it will start file system watcher. When file with target pattern will be changed, this extension will try to read it.
"vscode-coverage-highlighter.files": [
"coverage/coverage-final.json",
"coverage/lcov*.info",
"cov*.xml"
]
When the target files would be found, should extension highlight coverage immediately? Coverage could be hidden instead. Click on eye on status bar will highlight coverage.
"vscode-coverage-highlighter.defaultState": "enable"
This is an appearance option. When it is the true, a line will be highlighted wholly. Otherwise, only text will be highlighted.
"vscode-coverage-highlighter.wholeLine": false
The extension supports two colors. For covered and uncovered lines. It would be optimal to write colors in rgba notation. Because highlight with alpha channel wouldn't hide the other decorations.
You also can disable one or more colors completely. Just pass empty string for color and decoration won't be shown.
"vscode-coverage-highlighter.coveredColor": "rgba(20, 250, 20, 0.1)",
"vscode-coverage-highlighter.unCoveredColor": "rgba(255, 20, 20, 0.4)"
You also can enable following option to show diagnostic information on your Problems
tab. Each uncovered range will be mentioned there.
"vscode-coverage-highlighter.showDiagnostic": false
Open the Command Palette
and type Code Coverage
- Toggle coverage display: When text has been highlighted it will hide highlighting. By clicking on eye on your status bar you can do the same.