我正在使用 coverlet 和 .Net Core 开发 API,我开始进行单元测试(我为 .Net Core 找到的唯一工具是 coverlet)。
我得到了覆盖,但我只能得到像json
、xml
等文件
我需要查看 HTML 或更直观的内容才能快速处理测试。
这是我当前在终端上的输出:
+---------------------------+--------+--------+--------+
| Module | Line | Branch | Method |
+---------------------------+--------+--------+--------+
| rede-merchants-cancel-api | 12,5% | 0% | 16,7% |
+---------------------------+--------+--------+--------+
还有一部分带有json
的输出:
"Program.cs": {
"Program": {
"System.Void rede_merchants_cancel_api.Program::Main(System.String[])": {
"Lines": {
"9": 0,
"10": 0,
"11": 0
},
"Branches": []
},
"Microsoft.AspNetCore.Hosting.IWebHost rede_merchants_cancel_api.Program::BuildWebHost(System.String[])": {
"Lines": {
"14": 0,
"15": 0,
"16": 0
},
"Branches": []
}
}
}
最佳答案
如果您希望从带有源代码的代码覆盖率结果中看到一个漂亮而干净的 HTML 报告,您应该尝试 Daniel Palme 的 ReportGenerator . Coverlet 可以生成 cobertura
类型的 XML 报告,而 ReportGenerator 可以从中生成 HTML 报告。 Here您可以找到有关如何使用 coverlet 和 ReportGenerator 的精彩分步教程。 Cobertura 报告可以使用 this 轻松处理CI/CD 管道中的 Jenkins 插件。
关于unit-testing - 如何使用 .Net Core 和 coverlet 查看友好的单元测试报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51911135/