Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to integrate dotcover and Jenkins

How to integrate dotcover and Jenkis.

Any PDF or Guide?

I was able to run the dot cover through command line and it generate test results. However when I try to run in Jenkins through windows batch command it throws an error as

Command 'cover' doesn't support 2 unnamed arguments Type 'dotCover help' for usage.

Anything missing?

like image 684
user3756668 Avatar asked Jun 30 '14 07:06

user3756668


People also ask

Is dotCover command line free?

dotCover console runner is a command-line tool distributed free of charge as an archive, as a NuGet Package (Windows, macOS, Linux), or as a . NET global tool.

How does Jenkins check junit code coverage?

If you click on the Coverage Report icon, you will see code coverage for each package in your application, and even drill down to see the code coverage (or lack thereof) for an individual class (see Figure 2.31, “Jenkins lets you display code coverage metrics for packages and classes”).


1 Answers

I use dotCover from Jenkins. I have multiple DLL's that need testing, so my job will execute dotcover for each DLL, merge the test snapshots, and generate a HTML report. My Jenkins setup includes "HTML Publisher plugin" and "NUnit plugin"

First grab the command line tools and put it on the Jenkins server: dotCoverCommandLineTools

Run the command line tool in a windows batch command:

windows batch command to run tests

I had little luck trying to pass params into the command line, so I used the settings xml from dotCover (contents of dotCoverTRAEngineTest.xml):

    <?xml version="1.0" encoding="utf-8"?>
    <CoverageParams>
      <TargetExecutable>C:\NUnit-2.6.3\bin\nunit-console.exe</TargetExecutable>
<TargetArguments>C:\Jenkins\workspace\TRA.CodeCoverage\TRAEngine\TRAEngineTest\bin\x64\RduDev\TRAEngineTest.dll /xml:C:\Jenkins\workspace\TRA.CodeCoverage\TestReports\dotCoverTRAEngineTestRESULTS.xml</TargetArguments>
        <TargetWorkingDir></TargetWorkingDir>
      <Output>TRAEngineTestSnapshot.dcvr</Output>
    </CoverageParams>

Paths on the Jenkins server are hard coded because I'm lazy. I know it should be a parameter somehow but it's working for now.

Next I merge all the snapshots: merge

Contents of merge xml:

<?xml version="1.0" encoding="utf-8"?>
<MergeParams>
  <Source>TRAUnitTests.dcvr</Source>
  <Source>TRAEngineTestSnapshot.dcvr</Source>          
  <Output>MergedSnapshots.dcvr</Output>
</MergeParams>

Then run the report: report

Contents of report.xml:

<?xml version="1.0" encoding="utf-8"?>
<ReportParams>
  <Source>MergedSnapshots.dcvr</Source>
  <Output>CoverageReport.html</Output>
  <ReportType>HTML</ReportType>
</ReportParams>

All the .xml files above reside in a folder named "TestReports", and that's where I output all the results to. Jenkins will look there to publish the HTML report and nunit results: results publish

When it all works right you should get the dotCover report and the nunit results on the job page.

like image 58
Sean Avatar answered Oct 01 '22 21:10

Sean