Issue running dotCover in Teamcity with multiple test projects

Hi,

I have a C# solution which contains two test projects (one for unit tests and one for integration tests)

I am trying to setup automated builds for this project so that I can get dotCover statistics for both projects.

I have configured TeamCity to call a Powershell script to create the dotCover files for both projects as shown below. This all seems to run fine.

Task Coverage -depends Test  {
  if (($dotcover) -and (Test-Path($dotcover)))
  {
    
    Write-Host "Running dotcover: $dotcover with cfg: $coverage_cfg_file_unit" -ForegroundColor Green
    Exec { & $dotcover c $coverage_cfg_file_unit }
    Write-Host "Running dotcover: $dotcover with cfg: $coverage_cfg_file_integ" -ForegroundColor Green
    Exec { & $dotcover c $coverage_cfg_file_integ }
    Write-Host "Running dotcover merge: $dotcover with cfg: $coverage_cfg_file_merge" -ForegroundColor Green
    Exec { & $dotcover m $coverage_cfg_file_merge }
    Write-Host "Running dotcover report: $dotcover with cfg: $coverage_cfg_file_report" -ForegroundColor Green
    Exec { & $dotcover r $coverage_cfg_file_report }
        
    TeamCity-ImportDotNetCoverageResult -tool 'dotcover'-path $coverage_report_file
  }
  else {
    Write-Host "Dotcover exe does not exist at location: $dotcover"
  }
}

And in the TeamCity build logs, I can see that the dotCover steps all run successfully.

[17:08:35]: Coverage session started [08/03/2011 17:08:35]
[17:09:54]: Coverage session finished [08/03/2011 17:09:54]
[17:09:54]: Running dotcover: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotcover.exe with cfg: dotcoverIntegrationTests.xml
[17:09:54]: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved.
[17:09:56]: Coverage session started [08/03/2011 17:09:56]
[17:12:25]: Coverage session finished [08/03/2011 17:12:25]
[17:12:25]: Running dotcover merge: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotcover.exe with cfg: dotcoverMerge.xml
[17:12:26]: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved.
[17:12:28]: Snapshot merging started [08/03/2011 17:12:28]
[17:12:28]: Source snapshots number: 4
[17:12:28]: Merging snapshots 1-4
[17:12:29]: Snapshot merging finished [08/03/2011 17:12:29]
[17:12:29]: Running dotcover report: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotcover.exe with cfg: dotcoverReport.xml
[17:12:29]: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved.
[17:12:31]: Report generation started [08/03/2011 17:12:31]
[17:12:36]: Report generation finished [08/03/2011 17:12:36]
[17:12:36]: ##teamcity[importData type='dotNetCoverage' tool='dotcover' path='coverage.xml']
[17:12:36]: Importing data from 'coverage.xml' with 'dotNetCoverage' processor
[17:12:36]: Build Succeeded!

My problem is that after this happens, TeamCity itself seems to run dotCover and this is where we run into problems. Here is the log:

[17:12:36]: Build Time Report
[17:12:36]: ----------------------------------------------------------------------
[17:12:36]: Name Duration
[17:12:36]: ---- --------
[17:12:36]: Init 00:00:00.0748609
[17:12:36]: Clean 00:00:00.4691875
[17:12:36]: Compile 00:00:23.6646286
[17:12:36]: Test 00:03:39.2374522
[17:12:36]: Coverage 00:07:43.1783452
[17:12:36]: Total: 00:07:43.2124085
[17:12:36]: Process exited with code 0
[17:12:36]: NUnit report watcher
[17:12:36]: [NUnit report watcher] 1 file(s) found
[17:12:36]: [NUnit report watcher] D:\TeamCity\buildAgent\work\c661b11db8674ec6\output\build\UnitTestReport.xml found
[17:12:36]: Waiting for 1 service processes to complete
[17:12:36]: Processing 1 coverage report(s)
[17:12:36]: Generating coverage report by dotcover for files: [D:\TeamCity\buildAgent\work\c661b11db8674ec6\coverage.xml]
[17:12:36]: Merge dotCover reports (3s)
[17:12:40]: [Merge dotCover reports] Started dotCover: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotCover.exe merge D:\TeamCity\buildAgent\temp\buildTmp\dotcover2257888119473722608.xml
[17:12:40]: [Merge dotCover reports] Output: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved. Failed to read CoverageResult file 'D:\TeamCity\buildAgent\work\c661b11db8674ec6\coverage.xml'. There is an error in XML document (2, 2).
[17:12:40]: [Merge dotCover reports] dotCover exited with code: -11
[17:12:40]: [Merge dotCover reports] dotCover returned non-zero exit code.
[17:12:40]: Remove dotCover snapshot files (2s)
[17:12:42]: [Remove dotCover snapshot files] Started dotCover: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotCover.exe delete D:\TeamCity\buildAgent\temp\buildTmp\dotcover7788894927544150085.xml
[17:12:42]: [Remove dotCover snapshot files] Output: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved. Failed to read CoverageResult file 'D:\TeamCity\buildAgent\work\c661b11db8674ec6\coverage.xml'. There is an error in XML document (2, 2).
[17:12:42]: [Remove dotCover snapshot files] dotCover exited with code: -11
[17:12:42]: [Remove dotCover snapshot files] dotCover returned non-zero exit code.
[17:12:42]: Generate dotCover report (2s)
[17:12:45]: [Generate dotCover report] Started dotCover: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotCover.exe report D:\TeamCity\buildAgent\temp\buildTmp\dotcover2553150622569015381.xml
[17:12:45]: [Generate dotCover report] Output: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved. Failed to read CoverageResult file 'D:\TeamCity\buildAgent\temp\buildTmp\dotCover1753606822257361859Merge'. There is an error in XML document (0, 0).
[17:12:45]: [Generate dotCover report] dotCover exited with code: -11
[17:12:45]: [Generate dotCover report] dotCover returned non-zero exit code.
[17:12:45]: Remove dotCover snapshot files (2s)
[17:12:47]: [Remove dotCover snapshot files] Started dotCover: C:\TeamCity\buildAgent\plugins\dotCover\bin\dotCover.exe delete D:\TeamCity\buildAgent\temp\buildTmp\dotcover114009803187744801.xml
[17:12:47]: [Remove dotCover snapshot files] Output: JetBrains dotCover Console Runner v1.0.123.14. Copyright (c) 2009-2011 JetBrains s.r.o. All rights reserved. Failed to read CoverageResult file 'D:\TeamCity\buildAgent\temp\buildTmp\dotCover1753606822257361859Merge'. There is an error in XML document (0, 0).
[17:12:47]: [Remove dotCover snapshot files] dotCover exited with code: -11
[17:12:47]: [Remove dotCover snapshot files] dotCover returned non-zero exit code.
[17:12:47]: Generate dotCover HTML report
[17:12:47]: [Generate dotCover HTML report] Loading dotCover report file...
[17:12:47]: [Loading dotCover report file...] Failed to read dotCover report from: D:\TeamCity\buildAgent\temp\buildTmp\dotCover2150315164337187668Report. Premature end of file.
[17:12:47]: Failed to compute .NET Coverage statistics for dotCover report generator' Premature end of file.
[17:12:47]: Publishing artifacts
I don't understand why dotCover is run by TeamCity after the build has succeeded. Is TeamCity somehow configured to run dotCover after a build?
8 comments
Comment actions Permalink

TeamCity dotCover integration contains of two steps:
  1. collect coverage information from unit tests. This step produces a service message with a path to snapshot
  2. merge all reported snapshots and generated report

TeamCity uses service message to add dotCover snapshot to TeamCity:
http://confluence.jetbrains.net/display/TCD6/Manually+Configuring+Reporting+Coverage

That is why TeamCity generates and merges reports for you automatically. Why does it not suitable for you? If you need a way to disable TeamCity dotCover report generation, please feel free to post an issue into isse tracker at http://youtrack.jetbrains.net

BTW. Have you given a try to powershell runner plugin?
http://confluence.jetbrains.net/display/TW/PowerShell

0
Comment actions Permalink

i think the issue here is that he's using psake to push dotcover to TC...
i.e.
psake scripts are:
running the unit tests,
running dotcover
    calling generate on each project (i.e. -c)
    merge on the snapshots (i.e. -m)
    report (i.e. -r)

then using the teamcity import coverage result service message ("##teamcity[importData type='dotNetCoverage' tool='$tool' path='$path']")  (where $path = generated report path from above)

but even though this is being done explictly by the psake script, TC itself seems to be attempting the coverage also..

does that make sense?

0
Comment actions Permalink

To make TeamCity stop merging and publishing code coverage you may avoid setting the service message.

Why does it make sense for you to generate report from the script and not with TeamCity embedded abilities? TeamCity will generate HTML report for dotCover snapshots.

0
Comment actions Permalink

there's no options in the UI to use the built in dotcover support when choosing a command line runner type.
we want to run our psake builds, run the tests using psake etc.
we use the built in nunit report and provide the path that our build script outputs it to.
how would we do the same for the built in dotcover using the command line runner???

0
Comment actions Permalink

Sorry, you are using the service messages to report coverage as descibed here
http://confluence.jetbrains.net/display/TCD6/Manually+Configuring+Reporting+Coverage

This seem to be an issue in dotCover. Could you please consider reporting this issue to dotCover too.

Please try running the same build with newer version of dotCover. You should configure TeamCity with new path to dotcover with the following service message:

##teamcity[dotNetCoverage dotcover_home='<full path to dotcover>']


Thanks!

0
Comment actions Permalink

do i need to upgrade my entire teamcity install to get the latest dotcover (we're using the bundled version at the moment)?
regards

0
Comment actions Permalink

what version of dotcover do I need?
TC 6.0.3?

0
Comment actions Permalink

Please try this as dotCover:
http://confluence.jetbrains.net/display/DCVR/dotCover+Early+Access+Program

All you need is to make dotCover available on the build agent and use the server message I wrote in the build before calling any dotCover tasks.

0

Please sign in to leave a comment.