teamcitysonarqubedotcoversonar-runnerteamcity-7.1

TeamCity dotCover report path for Sonar


I'm trying to integrate the sonar analysis into by TeamCity build process. I have a NUnit build step which runs my unit tests and then runs dotCover for the coverage.

My next step is the sonar-runner. The configuration that currently exists is; gallio.mode=dotCover, sonar.gallio.mode=reuseReport but I also need sonar.gallio.reports.path.

Does anybody know the path to the dotCover report generated in the the previous step?


Solution

  • I couldn't find a way to do this using the built in NUnit runner. I managed to get it working by using a powershell build step to manually call the required commands.

    First step is to run the NUnit tests via Gallio within a dotCover cover call:

    & dotCover cover `
    /TargetExecutable="C:\Program Files\Gallio\bin\Gallio.Echo.exe" `
    /TargetArguments="/report-type:XML /report-name-format:test-report /runner:IsolatedProcess /report-directory:.\Gallio .\Path\Test.dll" `
    /Filters="+:WhatToCover" `
    /Output=coverage.snapshot
    

    The Gallio test report is then available to be picked up by Sonar with reuseReport, TeamCity automatically detects the test results.

    You can make TeamCity directly process the coverage snapshot by writing a service message to standard output:

    Write-Host "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='coverage.snapshot']"
    

    To get the coverage info into a format usable by Sonar you need to use the dotCover report command and the undocumented report type TeamCityXML:

    & dotCover report /Source=coverage.snapshot /Output=coverage-report.xml /ReportType=TeamCityXML