Jenkins 中的 Opencover NUnit Coverage 生成失败
Opencover NUnit Coverage generation fails in Jenkins
我正在尝试让 Jenkins 使用 OpenCover 生成覆盖率报告。我的项目有 NUnit 单元测试。
在 Jenkins 中,我正在执行以下脚本作为构建步骤:
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%
詹金斯日志:
[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.
问题出在 targetsargs
,改变了我处理路径中空格的方式:
-targetargs:"\"C:\Program Files (x86)\Jenkins\jobs\my-api\workspace\MyAPI.Tests\bin\Release\MyAPI.Tests.dll"
我正在尝试让 Jenkins 使用 OpenCover 生成覆盖率报告。我的项目有 NUnit 单元测试。
在 Jenkins 中,我正在执行以下脚本作为构建步骤:
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%
詹金斯日志:
[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.
问题出在 targetsargs
,改变了我处理路径中空格的方式:
-targetargs:"\"C:\Program Files (x86)\Jenkins\jobs\my-api\workspace\MyAPI.Tests\bin\Release\MyAPI.Tests.dll"