如何从 DotCover 控制台运行程序获取所覆盖可执行文件的退出代码?
我的组织正在致力于集成 DotCover 的控制台运行程序(描述 这里和此处)进入我们的 MSBuild通过自定义 MSBuild 任务基于构建过程。
正如您所期望的,我们将介绍 NUnit 在我们的单元测试程序集上的运行。虽然我们对 DotCover 生成的覆盖率结果非常满意,但我们发现我们的测试现在可以失败,而不会导致我们的构建失败。前进一步,后退两步。
DotCover(至少我们运行它的方式)完全隐藏了所覆盖进程的结果,包括控制台输出和退出代码。我希望它在这方面表现得更像 NCover —— 回显所覆盖进程的所有输出和退出代码。
有谁知道如何使用 DotCover 控制台运行程序实现其中任何一个?获取所覆盖进程的退出代码是最重要的,因为我们需要我们的构建在测试失败时失败。
My organization is working on integrating DotCover's console runner (described here and here) into our MSBuild-based build process via a custom MSBuild task.
As you might expect, we are covering NUnit runs over our unit test assemblies. While we are quite happy with the coverage results DotCover is generating, we've discovered that our tests can now fail without causing our build to fail. One step forward, two steps back.
DotCover (at least the way we are running it) completely hides the results of the covered process, both the console output and the exit code. I wish it behaved more like NCover in this regard -- echoing all output and the exit code from the covered process.
Does anyone know how to achieve either of these with the DotCover console runner? Getting the exit code of the covered process is most important, as we need our builds to fail in the event of a test failure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们使用 MSBuild 和 MSBuild 社区任务来使构建失败。
您可以使用 MSBuild.CommunityTasks 的 XmlRead 任务分析 dotCover 生成的输出 xml 文件。
We are using MSBuild and MSBuild Community Tasks to fail the build.
You can analyze the dotCover generated output xml file using the XmlRead task of MSBuild.CommunityTasks.
我遇到了同样的问题。
另一种解决方法是首先使用 dotCover 之外的测试运行程序运行单元测试。这将公开正确的返回代码。
然后作为第二步,运行 dotCover 来获取覆盖率结果。
希望这对某人有帮助。
I ran into the same issue.
An alternative workaround is to run your unit tests with your test runner outside of dotCover first. This will expose the correct return codes.
And then as a second step, run dotCover to get your coverage results.
Hope this helps somebody.
由于我需要快速解决方法,因此我添加了一个后处理步骤来抓取 DotCover 运行期间生成的 NUnit xml 文件以应对测试用例失败,如果发现任何错误,我都会使构建失败。我通过一个简单的自定义 MSBuild 任务完成了此操作:
这是从 MSBuild 调用的:(
我在包含结果文件的 ItemGroup 上循环调用它)
Since I needed a workaround quickly, I've added a post-processing step to scrape the NUnit xml file generated during the DotCover run for test case failures, and I fail the build if I find any. I did this via a simple custom MSBuild Task:
This is called from MSBuild thusly:
(I call it in a loop over an ItemGroup containing my result files)