0
votes

I'm trying to get Jenkins to generate coverage reports using OpenCover. My project has NUnit unit tests.

In Jenkins I'm executing the following script as a Build Step:

C:\test-tools\opencover\OpenCover.Console.exe -register:user "-target:C:\test-tools\nunit\bin\nunit3-console.exe" "-targetargs:C:\Program Files (x86)\Jenkins\jobs\my-api\workspace\MyAPI.Tests\bin\Release\MyAPI.Tests.dll" "-output:codecoveragereport.xml"

C:\test-tools\reportgenerator\ReportGenerator.exe "-reports:codecoveragereport.xml" "-targetdir:.\coverage"
C:\test-tools\OpenCoverToCoberturaConverter\OpenCoverToCoberturaConverter.exe -input:codecoveragereport.xml -output:codecoveragecobertura.xml -sources:%WORKSPACE%

Jenkins Log:

[workspace] $ powershell.exe "& 'C:\Users\SVC-JE~1.WIN\AppData\Local\Temp\hudson2552981969951052571.ps1'" Executing: C:\test-tools\nunit\bin\nunit3-console.exe NUnit Console Runner 3.4.1 Copyright (C) 2016 Charlie Poole

Runtime Environment OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1 CLR Version: 4.0.30319.42000

Test Files C:\Program Files (x86)\Jenkins\jobs\my-api\workspace\MyAPI.Tests\bin\Release\MyAPI.Tests.dll

System.Exception: Unable to acquire remote process agent at NUnit.Engine.Runners.ProcessRunner.CreateAgentAndRunner() at NUnit.Engine.Runners.ProcessRunner.LoadPackage() at NUnit.Engine.Runners.AbstractTestRunner.Load() at NUnit.Engine.Runners.AggregatingTestRunner.LoadPackage() at NUnit.Engine.Runners.AbstractTestRunner.Load() at NUnit.Engine.Runners.MasterTestRunner.LoadPackage() at NUnit.Engine.Runners.MasterTestRunner..ctor(IServiceLocator services, TestPackage package) at NUnit.Engine.TestEngine.GetRunner(TestPackage package) at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter) at NUnit.ConsoleRunner.ConsoleRunner.Execute()
at NUnit.ConsoleRunner.Program.Main(String[] args) Committing... No results, this could be for a number of reasons. The most common reasons are: 1) missing PDBs for the assemblies that match the filter please review the output file and refer to the Usage guide (Usage.rtf) about filters. 2) the profiler may not be registered correctly, please refer to the Usage guide and the -register switch.

1

1 Answers

0
votes

The problem was with targetsargs, changing the way I deal with spaces in the path:

-targetargs:"\"C:\Program Files (x86)\Jenkins\jobs\my-api\workspace\MyAPI.Tests\bin\Release\MyAPI.Tests.dll"