Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Visual Studio have code coverage for unit tests?

I am using Visual Studio 2015 Community edition, and I know that it has the option to create unit tests to test the code, but I don't see the option to test the code coverage, so I would like to know if Visual Studio has this option or if I have to use a third-party plugin.

If I have to use a third-party solution, would that be a good option?

like image 536
Álvaro García Avatar asked Sep 03 '15 07:09

Álvaro García


People also ask

Does Visual Studio code have code coverage?

Code coverage will highlight lines of code that are not covered by tests. It will list the uncovered lines under the problems window. And it conveniently shows the coverage ratio in the status bar.

How do you find unit testing code coverage?

Unit testing code coverageThe amount of source code a suite of unit tests exercises is called its code coverage. It isn't realistic -- or necessary -- to expect 100% code coverage through unit tests. The unit tests a development team creates depends on business needs and the application or applications' complexity.

How do I get fine code coverage in Visual Studio?

You have Fine Code Coverage working with VS 2022, you can access to it here https://github.com/FortuneN/FineCodeCoverage/releases and click on the 2022 file.


2 Answers

Only Visual Studio 2015 Enterprise has code coverage built-in. See the feature matrix for details.

You can use the OpenCover.UI extension for code coverage check inside Visual Studio. It supports MSTest, nUnit, and xUnit.

The new version can be downloaded from here (release notes).

like image 100
Toni Wenzel Avatar answered Oct 03 '22 11:10

Toni Wenzel


If you are using Visual Studio 2017 and come across this question, you might consider AxoCover. It's a free VS extension that integrates OpenCover, but supports VS2017 (it also appears to be under active development. +1).

VS Extension page

https://github.com/axodox/AxoTools

like image 22
Gordon Bean Avatar answered Oct 03 '22 10:10

Gordon Bean