你好!我试图找出在 Windows 10 中使用 MvvmCross 和 Visual Studio Community 2017 开发的 Xamarin 应用程序 (Xamarin.Android) 的代码覆盖率。
我们已经尝试过两次:
我们第一次创建了一个 MSTest 项目,我们能够在 Visual Studio 的测试资源管理器中运行,还可以使用 SonnarQube 导出输出。尽管我们可以检查我们的代码重复、错误、漏洞和代码气味,但 SonarQube 根本不会报告代码覆盖率。
我们意识到这是因为 Xamarin 项目使用 .NET Standard 而不是 .NET Framework,而 SonarQube 仅支持 .NET Framework。然后我们找到了这个带有 Mac 解决方案的链接,我引用了这个链接:
看起来我们遇到的最佳解决方案是使用 NUnitLite 运行程序将测试编译成可执行文件,然后使用日志分析器、mprof-report 和 ReportGenerator 生成最终的 html 文件:
例如
mono --debug --profile=log:coverage,covfilter=+MyNamespace,covfilter=-NotMyNamespace,output=coverage.mlpd MyTests.exe --noresult
mprof-report --reports=coverage --coverage-out=coverage.xml coverage.mlpd
mono ./packages/ReportGenerator.2.5.6/tools/ReportGenerator.exe -reports:coverage.xml -targetdir:report
firefox ./report/index.htm
所以我们将我们的测试项目转换为使用 NUnit。我们能够使用 NUnit.Adapter 将 NUnit 附加到 Visual Studio,我们能够从中生成可执行文件并从二进制安装程序 (*.msi) 安装 Mono for Windows (x64)。当我们运行第一个命令时,它会返回测试结果,但也会给出错误:
在主可执行文件中找不到“日志”分析器,也无法从“单分析器日志”加载它。
因此,没有覆盖输出。事实上,似乎也没有mprof-report安装,即使在 Mono 命令提示符中也是如此。
那么,考虑到我们绝不倾向于购买企业版软件,有什么方法可以找出我们的 Xamarin MvvmCross 项目的代码覆盖率是多少?如果是这样,怎么办?
慕桂英546537
胡说叔叔
随时随地看视频慕课网APP
相关分类