What are skipped tests in visual studio?

2020-08-09 05:28发布

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

9条回答
做个烂人
2楼-- · 2020-08-09 05:38

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.

查看更多
何必那么认真
3楼-- · 2020-08-09 05:38

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

查看更多
Lonely孤独者°
4楼-- · 2020-08-09 05:39

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

查看更多
疯言疯语
5楼-- · 2020-08-09 05:40

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.

查看更多
看我几分像从前
6楼-- · 2020-08-09 05:43

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.

查看更多
\"骚年 ilove
7楼-- · 2020-08-09 05:53

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

查看更多
登录 后发表回答