Microsoft Unit Test does not discover a Unit Test Class. Visual Studio 2017 Web API 2.0

Problem: Creating a Unit Test for a Web API can be complicated sometimes, a lot of things could go wrong. You could create a Unit Test project in a different folder than the project that you want to test, the versions of the Unit Test project could be different from the version of the application you are trying to create Unit Test for, and so forth.

Answer:

(1).  Things to check if you find yourself in a situation where Microsoft Unit Test does not discover a newly created Unit Test Class with Test Methods in it is to make sure the namespace in the Unit Class is correct.

(2). Try to clean, build and rebuild the project if you are using Microsoft Visual Studio. 

(3). Delete the Unit Test Class, and right-click on the Microsoft Unit Test project and navigate to "Add" then "Class" and recreate your Unit Test Class. That way the compiler knows about your newly created Unit Test Class. Chances are that the C# Compiler did not know well about your Unit Test Class.


Edit this Article
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy