How to enable Unit Tests reports from running NUnit from PartCover ?

I have an msbuild script

<ItemGroup>
    <tools-nUnit-addins_tcFiles Include="$(teamcity_dotnet_nunitaddin)-2.5.0.*" />
  </ItemGroup>
...
<Target Name="CodeCoverage" DependsOnTargets="Compile">
    <MakeDir Directories="$(build-reports-codeCoverage_dir)" />
    <Copy Condition=" '$(buildProcess_runsOnTC)' == 'true' " SourceFiles="@(tools-nUnit-addins_tcFiles)"  DestinationFolder="$(tools-nUnit-addins_dir)" />  
    <Exec Condition=" '$(tools-partCover_register)' == 'true' " Command="regsvr32.exe -s &quot;$(tools-partCover_driver)&quot;" />      
    <PropertyGroup>
      <args>--target $(tools-nUnit_runner)</args>
      <args>$(args) --target-work-dir $(build-bin-src-core-test_dir)</args>
      <args>$(args) --target-args &quot;$(src-core-test_projectName).dll /xml=..\..\..\$(build-reports_nUnitReportXml)&quot;</args>
      <args>$(args) --output $(build-reports_ccReportXml)</args>
      <args>$(args) --include [$(project_name).*]*</args>
      <args>$(args) --exclude [$(project_name).Core.Test]*</args>
    </PropertyGroup>
    <Message Text="##teamcity[testSuiteStarted name='$(src-core-test_projectName)']" />
    <Exec Command="$(tools-partCover_runner) $(args)" />
    <Message Text="##teamcity[testSuiteFinished name='$(src-core-test_projectName)']" />
    <Exec Condition=" '$(tools-partCover_register)' == 'true' " Command="regsvr32.exe -u -s &quot;$(tools-partCover_driver)&quot;" />
    <Copy SourceFiles="@(tools-partCover-xslt_transformationFiles)" DestinationFolder="$(build-reports-xslt_dir)" />
    <MSBuild.ExtensionPack.Xml.XmlTask TaskAction="TransForm"
                                       XmlFile="$(build-reports_ccReportXml)"
                                       XslTransformFile="$(build-reports-xslt_ccByAssemblyFile)"
                                       OutputFile="$(build-reports_ccReportByAssemblyHtml)">
    </MSBuild.ExtensionPack.Xml.XmlTask>
    <MSBuild.ExtensionPack.Xml.XmlTask TaskAction="TransForm"
                                   XmlFile="$(build-reports_ccReportXml)"
                                   XslTransformFile="$(build-reports-xslt_ccByClassFile)"
                                   OutputFile="$(build-reports_ccReportByClassHtml)">
    </MSBuild.ExtensionPack.Xml.XmlTask>
    <Xslt Inputs="$(build-reports_nUnitReportXml)" RootTag="mergedroot" Xsl="$(build-reports-xslt_nUnitTransformationFile)"
          Output="$(build-reports_nUnitReportHtml)" />



this part of script results in the following output:

Copying file from "C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.TeamCity.NUnitAddin-NUnit-2.5.0.dll" to "tools\NUnit\2.5.0.8189\addins\JetBrains.TeamCity.NUnitAddin-NUnit-2.5.0.dll".

[14:35:02]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Copying file from "C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.TeamCity.NUnitAddin-NUnit-2.5.0.pdb" to "tools\NUnit\2.5.0.8189\addins\JetBrains.TeamCity.NUnitAddin-NUnit-2.5.0.pdb".


[14:35:02]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] regsvr32.exe -s "tools\PartCover\2.2.0.34631\PartCover.CorDriver.dll"
[14:35:02]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] SM.NDefaultProject.Core.Test (2s)
[14:35:02]: [SM.NDefaultProject.Core.Test] tools\PartCover\2.2.0.34631\PartCover.exe --target tools\NUnit\2.5.0.8189\nunit-console.exe --target-work-dir build\bin\SM.NDefaultProject.Core.Test --target-args "SM.NDefaultProject.Core.Test.dll /xml=..\..\..\build\reports\NUnit-Report.xml" --output build\reports\CodeCoverage-Report.xml --include [SM.NDefaultProject.*]* --exclude [SM.NDefaultProject.Core.Test]*
[14:35:03]: [SM.NDefaultProject.Core.Test] NUnit version 2.5.0.8189 (Alpha-3)
[14:35:03]: [SM.NDefaultProject.Core.Test] Copyright (C) 2002-2008 Charlie Poole.\r\nCopyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.\r\nCopyright (C) 2000-2002 Philip Craig.\r\nAll Rights Reserved.
[14:35:03]: [SM.NDefaultProject.Core.Test] Runtime Environment -
[14:35:03]: [SM.NDefaultProject.Core.Test]    OS Version: Microsoft Windows NT 6.0.6001 Service Pack 1
[14:35:03]: [SM.NDefaultProject.Core.Test]   CLR Version: 2.0.50727.3074 ( Net 2.0.50727.3074 )
[14:35:05]: [SM.NDefaultProject.Core.Test] ...
[14:35:05]: [SM.NDefaultProject.Core.Test] Tests run: 3, Errors: 0, Failures: 0, Inconclusive: 0 Time: 0,561792 seconds
[14:35:05]: [SM.NDefaultProject.Core.Test]   Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] regsvr32.exe -u -s "tools\PartCover\2.2.0.34631\PartCover.CorDriver.dll"
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Creating directory "build\reports\xslt".
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Copying file from "tools\NUnit\2.5.0.8189\xslt\NUnit-Report.xsl" to "build\reports\xslt\NUnit-Report.xsl".
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Copying file from "tools\PartCover\2.2.0.34631\xslt\Report By Assembly.xslt" to "build\reports\xslt\Report By Assembly.xslt".
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Copying file from "tools\PartCover\2.2.0.34631\xslt\Report By Class.xslt" to "build\reports\xslt\Report By Class.xslt".
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Transforming: build\reports\CodeCoverage-Report.xml
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Transforming: build\reports\CodeCoverage-Report.xml
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Creating root tag \"mergedroot\".
[14:35:05]: [Project "SM.NDefaultProject.proj.teamcity.patch.tcprojx" (ReportsBuild target(s)):] Adding root attribute created=\"2009-03-06 14:35:05\".




The problem is that I see no "Tests" tab on the dashboard. Neither tests are being reported automatically - using team city nunit adding that is placed instide addins directory should be doing that, am I right?


Please help me, because I do not want to run my unit tests twice (this is I do not use NUnit task from MSBuild community tasks)
1 comment
Comment actions Permalink

Hello,

Could you please try copying TeamCity libraries into NUnit's lib or agent folder. In your code that would change the line:
<Copy Condition=" '$(buildProcess_runsOnTC)' == 'true' " SourceFiles="@(tools-nUnit-addins_tcFiles)"  DestinationFolder="$(tools-nUnit-addins_dir)" />
to
<MakeDir Directories="$(tools-nUnit-addins_dir)/addins" />
<Copy Condition=" '$(buildProcess_runsOnTC)' == 'true' " SourceFiles="@(tools-nUnit-addins_tcFiles)"  DestinationFolder="$(tools-nUnit-addins_dir)/addins" />

Does that works for you?

0

Please sign in to leave a comment.