我有一个围绕OpenCover的包装脚本,该脚本与NUnit一起运行。脚本如下:
我试图了解限制范围的工作原理,因此我使用相同的测试dll和NUnit过滤器运行了两次脚本,但程序集列表不同。
运行#1-限制从给定解决方案文件中获取的多个程序集
C:\Xyz\tip> Start-TestsWithCoverage .\UI\HcmAnywhereUnitTests\bin\Debug\HcmAnywhereUnitTests.dll -Where "namespace==HcmAnywhereUnitTests.Api" -SlnFile .\HcmAnywhere.sln
Using filter +[T4Utils]* +[TestContract]* +[DfVersioning]* +[XyzApi]* +[Xyz.Web.HcmAnywhereCommon]* +[OData]*
Executing: C:\Users\mkharitonov\AppData\Local\PackageManagement\NuGet\Packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe
Runtime Environment
OS Version: Microsoft Windows NT 10.0.17763.0
CLR Version: 4.0.30319.42000
Test Files
.\UI\HcmAnywhereUnitTests\bin\Debug\HcmAnywhereUnitTests.dll
Test Filters
Where: namespace==HcmAnywhereUnitTests.Api
Run Settings
ProcessModel: InProcess
DomainUsage: Single
DisposeRunners: True
WorkDirectory: C:\Xyz\tip
StopOnError: True
NumberOfTestWorkers: 1
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.7.2
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
Test Run Summary
Overall result: Passed
Test Count: 132, Passed: 132, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-06-11 22:57:47Z
End time: 2019-06-11 22:57:51Z
Duration: 4.163 seconds
Results (nunit3) saved as ~\AppData\Local\Temp\a24272_20190611185746\HcmAnywhereUnitTests.TestResult.xml
Committing...
Visited Classes 61 of 390 (15.64)
Visited Methods 202 of 2566 (7.87)
Visited Points 1125 of 6187 (18.18)
Visited Branches 523 of 4026 (12.99)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 61 of 548 (11.13)
Alternative Visited Methods 202 of 3166 (6.38)
Name Value
---- -----
CoverageResult ~\AppData\Local\Temp\a24272_20190611185746\HcmAnywhereUnitTests.CoverageResult.xml
TestResult ~\AppData\Local\Temp\a24272_20190611185746\HcmAnywhereUnitTests.TestResult.xml
C:\Xyz\tip>
要点:
+[T4Utils]* +[TestContract]* +[DfVersioning]* +[XyzApi]* +[Xyz.Web.HcmAnywhereCommon]* +[OData]*"
运行#2-由一个程序集限制
C:\Xyz\tip> Start-TestsWithCoverage .\UI\HcmAnywhereUnitTests\bin\Debug\HcmAnywhereUnitTests.dll -Where "namespace==HcmAnywhereUnitTests.Api" -AssemblyNames DataSvc
Using filter +[DataSvc]*
Executing: C:\Users\mkharitonov\AppData\Local\PackageManagement\NuGet\Packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe
Runtime Environment
OS Version: Microsoft Windows NT 10.0.17763.0
CLR Version: 4.0.30319.42000
Test Files
.\UI\HcmAnywhereUnitTests\bin\Debug\HcmAnywhereUnitTests.dll
Test Filters
Where: namespace==HcmAnywhereUnitTests.Api
Run Settings
ProcessModel: InProcess
DomainUsage: Single
DisposeRunners: True
WorkDirectory: C:\Xyz\tip
StopOnError: True
NumberOfTestWorkers: 1
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETFramework,Version=v4.7.2
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
Test Run Summary
Overall result: Passed
Test Count: 132, Passed: 132, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-06-11 22:58:56Z
End time: 2019-06-11 23:00:00Z
Duration: 63.416 seconds
Results (nunit3) saved as ~\AppData\Local\Temp\a24272_20190611185855\HcmAnywhereUnitTests.TestResult.xml
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.
Name Value
---- -----
CoverageResult ~\AppData\Local\Temp\a24272_20190611185855\HcmAnywhereUnitTests.CoverageResult.xml
TestResult ~\AppData\Local\Temp\a24272_20190611185855\HcmAnywhereUnitTests.TestResult.xml
C:\Xyz\tip>
要点:
"+[DataSvc]*"
检查结果
C:\Xyz\tip> cat ~\AppData\Local\Temp\a24272_20190611185746\HcmAnywhereUnitTests.CoverageResult.xml | sls "ModulePath.+DataSvc"
<ModulePath>C:\Xyz\tip\UI\HcmAnywhereUnitTests\bin\Debug\DataSvc.dll</ModulePath>
C:\Xyz\tip> cat ~\AppData\Local\Temp\a24272_20190611185855\HcmAnywhereUnitTests.CoverageResult.xml | sls "ModulePath.+DataSvc"
C:\Xyz\tip>
有一个间接证据表明DataSvc在第二次运行中已配置文件-NUnit完成完全相同的测试需要63秒,而之前需要4秒。实际上,DataSvc远远大于首次运行中提供的解决方案中的所有程序集。所以,这对我来说很有意义。
但是为什么没有覆盖?怎么了?