Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upShow Pester CodeCoverage data as green/red lines of source text #495
Comments
daviwil
added
the
Issue-Enhancement
label
Feb 9, 2017
daviwil
added this to the
Backlog milestone
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
gerane
commented
Mar 17, 2017
•
I would love to see this. A red\green icon in the gutter or other decorators would be a nice option as well so it doesn't conflict with other errors. I have been playing with this background task that lights up CodeCoverage, but after looking at other Code Coverage extensions, it seems like a background problem matcher task might not be the best option in the long term. Though, if you just wanted code coverage and not also failed test matches, you could delete the problem matcher for the tests and get just code coverage. Here are a few example extensions I glanced at. I really like some of what the Wallaby.js extension does. https://marketplace.visualstudio.com/items?itemName=WallabyJs.wallaby-vscode Here is an example background task Task runner that matches for code coverage and failed tests. {
"version": "0.1.0",
"windows": {
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe"
},
"linux": {
"command": "/usr/bin/powershell"
},
"osx": {
"command": "/usr/local/bin/powershell"
},
"isShellCommand": true,
"showOutput": "always",
"args": [
"-NoProfile", "-ExecutionPolicy", "Bypass"
],
"tasks": [
{
"taskName": "Watch.Project",
"isTestCommand": true,
"suppressTaskName": true,
"args": [
"Write-Host 'Watching Project';",
"Import-Module -Name Pester -RequiredVersion 3.4.3 -Force;",
"Import-Module -Name PowerShellGuard;",
"New-Guard -Path \"${workspaceRoot}\" -PathFilter \"*.ps1\" -MonitorSubdirectories -TestPath \"${workspaceRoot}\\Tests\" -TestCommand {Write-Host \"Invoking Watch.Project\"; Invoke-Pester -CodeCoverage (gci \"${workspaceRoot}\\${workspaceRootFolderName}\\*.ps1\" -recurse) -PesterOption @{IncludeVSCodeMarker=$true}; Write-Host \"Finished Watch.Project\"} -Wait;"
],
"isBackground": true,
"problemMatcher": [
{
"owner": "Watch.Project",
"fileLocation": "absolute",
"pattern": [
{
"regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
"message": 1
},
{
"regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$",
"file": 1,
"line": 2
}
],
"watching": {
"activeOnStart": true,
"beginsPattern": "^Invoking Watch\\.Project$",
"endsPattern": "^Passed:\\s\\d+\\sFailed:\\s\\d+\\sSkipped:\\s\\d+\\sPending:\\s\\d+\\sInconclusive:\\s\\d+\\s$"
}
},
{
"owner": "Watch.Project.CodeCoverage",
"fileLocation": ["relative", "${workspaceRoot}\\${workspaceRootFolderName}"],
"pattern": [
{
"regexp": "^([Private|Public][\\s\\S]+\\.ps1).*\\s(\\d+)\\s(.*)$",
"message": 3,
"file": 1,
"line": 2
}
],
"watching": {
"activeOnStart": true,
"beginsPattern": "^Invoking Watch\\.Project$",
"endsPattern": "^Finished Watch\\.Project.*$"
}
}
]
}
]
} |
rkeithhill commentedFeb 9, 2017
When you run Pester with -CodeCoverage it will give you a percentage of code coverage but it also gives you every line that is not covered:
It would be cool if we could use this data to color script text red/green (covered/not covered) like Visual Studio does.