问题
I am new to NUnit testing. I was able to write test cases for my functions, now what I want is to know the code coverage for my test cases. For that I use OpenCover. But I don't know how to install and get OpenCover to work with Visual Studio 2015, can anyone guide me to install OpenCover for Visual Studio and provide help to see the code coverage in Visual Studio?
回答1:
The best solution I found for code coverage in Visual Studio is as follows:
- Open Visual Studio 2017
- Go to Tools->Extensions and Updates
- Go to "Online", in the search (top right of the window) type "AxoCover"
- Click install, follow the instructions (i.e. close Visual Studio to start the install)
- Reopen Visual Studio
- Build your project
- Go to Tools->AxoCover
- Under the "Tests" tab right click your top directory and go "Cover tests"
- Click on the "Report" tab
回答2:
You need some VS extension to include the coverage results in VS. One example: https://visualstudiogallery.msdn.microsoft.com/6950a046-8919-4935-8542-c6f37956f688/view/
- you need OpenCover installed/present in solution
- you need NUnitConsole installed/present in solution
- it does not support VS2017
- NUnit3 supported only when you do a custom build from git (not in latest release)
I have nothing to do with this extension, it is just working for me. Use at your own risk :)
If you mean it and you can spent some $ go for http://www.ncrunch.net/
来源:https://stackoverflow.com/questions/43089457/how-to-run-an-nunit-test-in-visualstudio-with-opencover-code-coverage