Code coverage and test results for .NET Core projects in VSTS

北慕城南 提交于 2019-12-21 05:46:16

问题


How do we enable code coverage and test results for .NET Core projects in VSTS?

Currently, it is not enabled for a .NET Core test task.


回答1:


You can use Visual Studio Test task with /framework:".NETCoreApp,Version=v1.1" option to run .NET Core tests. (Specify vstest.console.exe path in a Visual Studio Test task: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\TestPlatform)

An article about code coverage: Working with Code Coverage.

But there is the issue when uploading a coverage file: Publish VSTest: Skipping attachment as it exceeded the maximum allowed size or not available on disk.

On the other hand, you may get an empty-result-generated issue: Running code coverage from Visual Studio 2017 always results in "Empty results generated: No binaries were instrumented..".

To conclude, you can track the update of these issues, and try again after the issues have been fixed.




回答2:


This is half an answer (as I'm not a fan of code coverage).

First get dotnet test to output a trx file with the test results by passing the arguments -l trx

Then follow it up with the Publish Test Results task.

Here are the options I used:

And you will get your results (P.S. It's a very simple app):

I'm guessing that a similar approach for code coverage can be attained.



来源:https://stackoverflow.com/questions/46159067/code-coverage-and-test-results-for-net-core-projects-in-vsts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!