What are skipped tests in visual studio?

做~自己de王妃 提交于 2020-06-11 16:15:57

问题


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


回答1:


Check if the test has a Ignore attribute.




回答2:


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




回答3:


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.




回答4:


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




回答5:


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:


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.




回答7:


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




回答8:


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




回答9:


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



来源:https://stackoverflow.com/questions/12840020/what-are-skipped-tests-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!