Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

dotcover: dotcover print coverage results using cmd line


# first run the tests with coverage, generating a snapshot
dotcover cover 
    --targetExecutable="nunit3-console.exe" 
    --targetArguments="..." 
    --output="coverage-results.snapshot"

# then, generate the JSON report 
dotcover report --Source="results.snapshot" --Output="coverage-results.json" --ReportType="JSON"

# then, generate the HTML report (a nice way of examining results manually)
dotcover report --Source="results.snapshot" --Output="coverage-results.html" --ReportType="HTML"

# Read the JSON file (my runners are on windows, so I'm using powershell)
$coverageJson = (Get-Content "coverage-results.json" -Raw) | ConvertFrom-Json

# Print the top level coverage result
Write-Host "Statements: $($coverageJson.CoveragePercent)%"

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x