41

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:

Skipped Tests

Jean-Bernard Pellerin
  • 12,556
  • 10
  • 57
  • 79
testCoder
  • 7,155
  • 13
  • 56
  • 75
  • 1
    Do you have a test settings file? – kevin_fitz Oct 11 '12 at 13:06
  • Yes, i have TestSettings.testsettings file. – testCoder Oct 11 '12 at 13:10
  • Is the test settings file specifying which tests to run? Mainly, under Folders, is the folder where your tests are located included? – kevin_fitz Oct 11 '12 at 13:13
  • Where can i find it, can you show screenshot? – testCoder Oct 11 '12 at 13:29
  • try [this](http://msdn.microsoft.com/en-us/library/ee256991.aspx#VSTestSettingsUnitTest) – kevin_fitz Oct 11 '12 at 13:33
  • The screenshot doesn't look like Visual Studio's default test runner. What IDE/Test runner is this? – bryanbcook Oct 12 '12 at 12:19
  • I have installed Resharper, but it have his own "Unit test Sessions" window. – testCoder Oct 12 '12 at 12:33
  • Thank you kevin_fitz. I didn't read everything you said but just your questioning about whether he has a test settings file led me to solve my own issue. My tests were skipping because I had accidentally left 'remote execution' on in my test settings files which was fine before but now and I was intending on local execution. – ajeetdl Apr 15 '13 at 09:18
  • 8
    I know it's been a while, but have you managed to solve this? I've run into the same issue, and i can't find a solution anywhere. – andyroschy May 14 '13 at 18:16
  • Are these tests written using MSTest framework? Or do they use NUnit. xUnit.NET or other frameworks. If yes would you install the corresponding test runner plugin? – Spock Jul 05 '13 at 12:30
  • @andyroschy did you manage to solve this problem? – Spock Jul 10 '13 at 09:53
  • This sounds weird but I get this problem on Windows 10 with Visual Studio 2015, but it works fine with the exact same project copy/pasted over to Windows 7 with the same version of Visual Studio – jrh Dec 06 '19 at 21:20
  • After a reboot (of the whole computer, not just Visual Studio) the problem seemed to go away for me. – jrh Dec 29 '19 at 00:25

10 Answers10

34

Check if the test has a Ignore attribute.

Sridarshan
  • 1,268
  • 3
  • 13
  • 15
8

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

Jean-Bernard Pellerin
  • 12,556
  • 10
  • 57
  • 79
4

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.

Ryan Cox
  • 938
  • 1
  • 7
  • 22
4

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.

Tony Hopkinson
  • 20,172
  • 3
  • 31
  • 39
  • I've had similar issues when an Exception is thrown from the ClassInitialize, class constructor, or even default initialized attributes.... Not the case this time as I am hitting this issue with an empty class. – AdIch Mar 23 '22 at 00:50
  • Maybe its skipped it Because its empty. There seems to be plethora of reasons why this happens, Personally I think Test32 neds an upgrade. I have a project where I can't debug tests. All seems a bit flaky. – Tony Hopkinson Mar 24 '22 at 09:09
3

Also caused by testing a 64-bit project but test->Test Settings->Default Processor Architecture=x86

smirkingman
  • 6,167
  • 4
  • 34
  • 47
2

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

RedAces
  • 319
  • 1
  • 3
  • 16
2

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...

NielW
  • 3,626
  • 1
  • 30
  • 38
1

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.

Arthur S.
  • 202
  • 2
  • 9
1

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" />
Giles Roberts
  • 6,407
  • 6
  • 48
  • 63
  • 1
    This was the problem for me, and it didn't give me any message about it. It just skipped the test until I removed the script from the testrunconfig file. – Ed Bayiates Jan 03 '23 at 17:08
0

In xUnit, tests marked with FactAttribute for which Skip property is set to something are skipped.

Borislav Ivanov
  • 4,684
  • 3
  • 31
  • 55