I tried to run Visual Studio tests in ASP.NET MVC by pressing "Run All" but all tests were skipped. Why did this happen and how can I run all tests? Here is a screenshot:
Check if the test has a Ignore attribute.
Tests which use the Inconclusive
result will appear as skipped. So VS 2010 inconclusive == VS 2012 skipped
ex:
Assert.Inconclusive("This test didn't exactly fail, but we can't be certain the results are good.")
Will read as skipped in the test window
The Test Settings file you're pointing to could be invalid. Make sure the settings file has the right parameters (either remote or local, etc.), and then go to Tests>Test Settings>Select Test Settings File
in the toolbar to select the valid file.
I got this in VS 2015, along with QTAgent32 stopped working etc. Turned out to be nothing to do with test settings and was in fact a stack overflow (I kid you not) in the class I was testing.
I had several tests failing, and a whole swathe of others skipped when the agent went down. I commented out all the tests in the impacted area, until run all worked, then pulled them back in until a fail, then to see the actual SO exception I had to debug the test.
Then I face palmed a few times and fixed it. Unlikely scenario, but you never know.
In addition to what's been mentioned here, check that the TestClass does not also have the Ignore attribute (not just the test method.) This bit me once...
Also caused by testing a 64-bit project but test->Test Settings->Default Processor Architecture=x86
Assuming that one of your tests beforehand didn't fail, your tests may have been skipped due to insufficient privileges.
You can use the "TestCategories" annotation on your tests. Mark them with:
[TestCategory("Admin") TestMethod()]
public Void Test1()
{
...
}
And then exclude the category:
mstest /testcontainer:MyTestprojectName.dll /category:"!Admin"
You can use multiple categories on each test. For in-depth info: http://msdn.microsoft.com/en-us/library/dd286683.aspx
I know this is an old issue and there's no accepted answer, but maybe this will help someone.
In Test Explorer (Tests -> Windows -> Test Explorer), you can see all the tests that were skipped. If you double-click on test name, it will open the actual Test code. Check if the test has an [Ignore] attribute and remove it if you want to run the test. (as @Sridarshan suggested)
P.S. I had NUnit tests.
I had a setup script defined in my TestSettings.testsettings file that did not exist on my development machine.
<Scripts setupScript="C:\Deployment\UnitTestSetup.cmd" />
In xUnit, tests marked with FactAttribute
for which Skip
property is set to something are skipped.
Might not be relevant for this exact case, but if none of your NUnit tests are running in the test explorer and they are being skipped, you might want to check if you have Microsoft.Net.Test.Sdk nuget installed. It is needed.
So, in Visual Studio Professional 2022, this was happening to me, because I was in "Folder View" instead of "Solution View."
In the Solution Explorer (right side of the screen in my setup), at the top, there's a button that lets you switch between viewing the solution as a .sln file (and all associated files), or simply viewing things as a folder tree.
For some reason, when I was in "Folder View," three of my 72 tests were skipped silently. Even clicking on them in the Test Explorer and manually choosing "Run" did nothing. However, switching views as described above via the Solution Explorer did the trick.
© 2022 - 2024 — McMap. All rights reserved.