I configured dotCover
to be run from our GitLab CI server.
It correctly runs the tests, produces the required output and the CI is configured to store the coverage HTML output in the GitLab artifacts. This works flawlessly.
What I'm trying to do is to read the total coverage output from the dotCover.exe console runner and parse it in gitlab CI. I read the dotCover documentation but I did not find a method to output a line containing the coverage to console. Gitlab CI can only read coverage values from the sdout of the ci job, matching it with a custom regex.
This is my config.xml
:
<?xml version="1.0" encoding="utf-8"?>
<AnalyseParams>
<TargetExecutable>C:\NUnit\nunit3-console.exe</TargetExecutable>
<TargetArguments>--agents=1 MyDll.Spec.dll MyDll2.Spec.dll</TargetArguments>
<Output>cover/AppCoverageReport.html</Output>
<ReportType>html</ReportType>
<Scope>
<ScopeEntry>MyApp\bin\x86\Release\net461\MyApp.*.dll</ScopeEntry>
<ScopeEntry>MyApp\bin\x86\Release\net461\*.exe</ScopeEntry>
</Scope>
<Filters>
<ExcludeFilters>
<FilterEntry>
<ModuleMask>*.Spec</ModuleMask>
</FilterEntry>
</ExcludeFilters>
</Filters>
</AnalyseParams>
and I run it with .gitlab-ci.yml:
C:\dotCover\dotCover.exe analyse config.xml /TargetWorkingDir=.
Is there a way to view this value in GitLab CI? Am I missing something obvious?
Thank you
I ended up reading the HTML output file of dotCover
and parsing the output.
Luckily the total coverage is at an easily parse-able portion of the output file. The coverage regex is
'/= \[\["Total",\d+\.?\d+/'
This is my final .gitlab-ci.yml
file (for Windows runner, dotCover is windows-only):
my_job:
# your job configuration
# ...
scripts:
# build the solution here, ...
- dotCover.exe analyse dotCover.xml /TargetWorkingDir=.
- type cover\AppCoverageReport.html
coverage: '/= \[\["Total",\d+\.?\d+/'
Not a very long-term solution but it works for now, at least until I update dotCover
.