在 mono 上使用 Profiler 收集代码覆盖信息不包括被测试的 dll 的程序集

Using Profiler on mono to gather code coverage information does not include the assemblies of the tested dll

目前我正在 Mac 上使用 Xamarin Studio 开发 Xamarin 项目。我创建了一个 NUnit 测试项目来测试核心 PCL 4.5 库。在命令行上:

 mono --debug  --profile=log:report,coverage nunit3-console.exe bin/Debug/MyProject.Core.Tests.dll 

以及我在输出中采用的覆盖率摘要:

Coverage Summary: nunit.engine (/Users/Stam/Desktop/NUnit/nunit.engine.dll) 39% covered (656 methods - 258 covered) NUnit.Engine.Services.ResultService 100% covered (4 methods - 4 covered) NUnit.Engine.Extensibility.ExtensionPoint 25% covered (12 methods - 3 covered) NUnit.Engine.Services.TestFilterService 50% covered (2 methods - 1 covered) NUnit.Engine.Agents.TestAgent 50% covered (10 methods - 5 covered) NUnit.Engine.Internal.DirectoryFinder 75% covered (4 methods - 3 covered) NUnit.Engine.Services.TestAgency 88% covered (17 methods - 15 covered) NUnit.Engine.Internal.SettingsStore 75% covered (4 methods - 3 covered) ..... more nunit assemblies here

这里没有包含到 dll 中的程序集。

  1. 有什么办法吗?

  2. 如果没有,我可以在 Mac 上使用任何其他非商业测试代码覆盖工具吗?

您需要 运行 nunit3-console 通过以下方式处理您的测试程序集:

--process=PROCESS

--inprocess

例子

注意:这将删除所有 NUnit 程序集和包含 [Test] 的测试程序集,因此输出仅包含用户代码

mono \
--debug \
--profile=log:coverage,onlycoverage,\
covfilter=-nunit3-console,\
covfilter=-nunit.framework,\
covfilter=-Mono.Cecil,\
covfilter=-NUnit.Engine,\
covfilter=-NUnit.Core,\
covfilter=-nunit.core,\
covfilter=-nunit.engine,\
covfilter=-nunit.v2.driver,\
covfilter=-TestAssembly \
packages/NUnit.ConsoleRunner.3.5.0/tools/nunit3-console.exe \
--noh \
--inprocess \
CodeCoverage/bin/Debug/TestAssembly.dll

输出:

>>mprof-report --reports=coverage output.mlpd

Coverage Summary:
    MyAssembly (/Users/sushi/Projects/CodeCoverage/CodeCoverage/bin/Debug/MyAssembly.dll) 50% covered (2 methods - 1 covered)
        MyAssembly.MyClass 50% covered (2 methods - 1 covered)