Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2013 feature Code Lens with NUnit

In the new Visual Studio 2013 there is a nice new feature called Code Lens (I think that it is only in the Ultimate version). Regarding methods, besides it shows references (how many and where) it also shows some information about versioning when working in team and tests statistics so that you know how many tests using the method are passing and how many failing.

I assume that this works perfectly with test projects embedded in Visual Studio, but does it work with NUnit? We are using NUnit for unit testing and we are trying to decide whether or not to move to VS2013 and one of reasons would be this new feature that we would sure like to use to its full extent if it support NUnit.

Do you have any experience with it?

like image 701
Ondrej Janacek Avatar asked Nov 01 '13 11:11

Ondrej Janacek


People also ask

How do I enable CodeLens code in Visual Studio?

VS Code comes with CodeLens for TypeScript. You can enable it in User Settings with "typescript. referencesCodeLens. enabled": true .

How do I test code coverage in Visual Studio?

On the Test menu, select Analyze Code Coverage for All Tests. You can also run code coverage from the Test Explorer tool window. Show Code Coverage Coloring in the Code Coverage Results window. By default, code that is covered by tests is highlighted in light blue.

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.


2 Answers

The tested by and test status indicators are powered by the test explorer.

So if your NUnit tests show up in the test explorer, they should also show up in CodeLens.

like image 85
John Gardner Avatar answered Oct 19 '22 18:10

John Gardner


I don't have enough reputation points to add as a comment to John Gardner's reply, so I adding a new answer.

I added an answer to a similar question here - CodeLens only finds tests that are written in MSTests

Summary of that answer - you need to create a new Unit Test Project and add a reference to NUnit to that new Unit Test Project. That is how I got it to work with VS2013 and NUnit (along with the NUnit Test Provider) so now the tests show up in VS2013 Test Explorer window and in CodeLens.

like image 36
Jim Avatar answered Oct 19 '22 20:10

Jim