CodeLens only detects tests written in MSTests

I recently installed Visual Studio 2013 and CodeLens is awesome! The problem that I find is that whenever I open a class file that has methods in it, it does not seem to find unit tests associated with this method if it is not written in MSTest. Is there anything I need to do so that it can find other Unit tests like MSpec?

enter image description here

Is it because machine specifications have a different approach when creating unit tests against MSTest or another testing framework there?

+5
source share
2 answers

Proven status indicators for testing and testing are powered by the test conductor.

So, if your MSpec tests appear in the test explorer and are written in C # or VB, they should also appear in CodeLens.

(same answer as Visual Studio 2013 Object with NUnit lens )

I just did this with NUnit on a clean machine, installing Nunit and the Nunit extension in the extension manager. Here, Main shows one reference and one passing test, and the test itself shows a check mark after a successful launch.

enter image description here

+3
source

I did the same thing that John Gardner showed in his answer, except that I divided it into 2 projects (to imitate the setting that I worked with in my real solution). This did not work at first, although I could see the tests in Test Explorer. After a short search, I came across the correct answer for my situation.

Turns out you need:

(1) Create a new Unit Test project (and not a class library)

(2) Add the NUnit link to the Unit Test project (I used NuGet) and installed the NUnit test adapter in VS2013

(3) Transfer your tests to this new project

(4) After saving and assembling, now you can return to your production code and see the message "x / y transmission" and view the unit tests in the Test Explorer window.

Most of us who have been using NUnit for a long time are used to create class libraries for our code instead of Unit Test Projects. It would be nice if the CodeLens documentation directly touched on this (the documentation reads: "Test status indicators appear automatically in test projects," which was my hint).

+1
source

Source: https://habr.com/ru/post/957184/


All Articles