'0 Total Tests - 0 passed,0 failed ,0 skipped even after having tests in the class
While running unit test in Visual studio , i was getting 0 Total Tests - 0 passed,0 failed ,0 skipped even after having tests in the class.
Solution 1:[1]
In Nunit, if there is an exception in loading test setup or execution it will result in above. From Visual studio menu open debug=>output and select Test window and see are there any exceptions thrown when tests are run. In my case in project1 i have nunit2 (refernce), in project2 i have nunit3 which referred project1 which is causing conflict and unable to execute.
if you resolve the exception it should work
Solution 2:[2]
Check if you have runsettings file in your solution or if there is one selected under VS -> Test -> Configure Run Settings. If this is chosen, uncheck it. Remove the file. This fixed for me.
Solution 3:[3]
In Case anyone is still struggling with this, installing "MSTest.TestAdapter" solved my issue.
Solution 4:[4]
For me a simple "Clean Solution" worked.
Solution 5:[5]
Ensure the access modifier of the class is public instead of internal. If it is internal none of the [Fact]s in the class will register as tests within the Test Explorer, nor will they run.
Solution 6:[6]
Here in my case the issue was different . In VS Unit tests are being identified based on Test class. In my case , there were no access modifier for the class and which caused the issue .VS unable to identify the test methods for the particular class.
class ControllerTests
{
public Controller _Controller;
[TestMethod()]
}
After adding public to the class ,it worked fine.
Public class ControllerTests
{
public Controller _Controller;
[TestMethod()]
}
Solution 7:[7]
Installing Microsoft.NET.Test.Sdk package from nuget package manager solved my issue.
I also have xunit and xunit.runner.visualstudio package installed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Indu Aravind |
| Solution 3 | Crime Master Gogo |
| Solution 4 | Denis G. Labrecque |
| Solution 5 | user358041 |
| Solution 6 | Bijay Nandagiri |
| Solution 7 |
