视觉工作室中有哪些跳过的测试?

时间:2021-10-09 15:39:05

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:

我试图通过按“全部运行”在ASP.NET MVC中运行Visual Studio测试,但是跳过了所有测试。为什么会发生这种情况?如何运行所有测试?这是一个截图:

视觉工作室中有哪些跳过的测试?

6 个解决方案

#1


12  

Check if the test has a Ignore attribute.

检查测试是否具有“忽略”属性。

#2


6  

Tests which use the Inconclusive result will appear as skipped. So VS 2010 inconclusive == VS 2012 skipped

使用Inconclusive结果的测试将显示为已跳过。所以VS 2010没有结论== VS 2012跳过了

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


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:

您可以在测试中使用“TestCategories”注释。标记他们:

[TestCategory("Admin") TestMethod()]
public Void Test1()
{
   ...
}

And then exclude the category:

然后排除类别:

mstest /testcontainer:MyTestprojectName.dll /category:"!Admin"

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

您可以在每个测试中使用多个类别。有关深入信息:http://msdn.microsoft.com/en-us/library/dd286683.aspx

#4


2  

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.

您指向的测试设置文件可能无效。确保设置文件具有正确的参数(远程或本地等),然后转到工具栏中的“测试”>“测试设置”>“选择测试设置文件”以选择有效文件。

#5


2  

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.

我在VS 2015中得到了这个,随着QTAgent32停止工作等。原来与测试设置无关,实际上是我正在测试的类中的堆栈溢出(我不是你的孩子)。

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.

我有几次测试失败,当代理人失败时,一大堆其他人都跳过了。我注释了受影响区域中的所有测试,直到运行全部工作,然后将它们拉回来直到失败,然后看到我必须调试测试的实际SO异常。

Then I face palmed a few times and fixed it. Unlikely scenario, but you never know.

然后我面对几次并修好了。不太可能的情况,但你永远不知道。

#6


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)

在测试资源管理器(测试 - > Windows - >测试资源管理器)中,您可以看到所有跳过的测试。如果双击测试名称,它将打开实际的测试代码。检查测试是否具有[Ignore]属性,如果要运行测试,请将其删除。 (正如@Sridarshan建议的那样)

P.S. I had NUnit tests.

附:我有NUnit测试。

#1


12  

Check if the test has a Ignore attribute.

检查测试是否具有“忽略”属性。

#2


6  

Tests which use the Inconclusive result will appear as skipped. So VS 2010 inconclusive == VS 2012 skipped

使用Inconclusive结果的测试将显示为已跳过。所以VS 2010没有结论== VS 2012跳过了

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


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:

您可以在测试中使用“TestCategories”注释。标记他们:

[TestCategory("Admin") TestMethod()]
public Void Test1()
{
   ...
}

And then exclude the category:

然后排除类别:

mstest /testcontainer:MyTestprojectName.dll /category:"!Admin"

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

您可以在每个测试中使用多个类别。有关深入信息:http://msdn.microsoft.com/en-us/library/dd286683.aspx

#4


2  

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.

您指向的测试设置文件可能无效。确保设置文件具有正确的参数(远程或本地等),然后转到工具栏中的“测试”>“测试设置”>“选择测试设置文件”以选择有效文件。

#5


2  

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.

我在VS 2015中得到了这个,随着QTAgent32停止工作等。原来与测试设置无关,实际上是我正在测试的类中的堆栈溢出(我不是你的孩子)。

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.

我有几次测试失败,当代理人失败时,一大堆其他人都跳过了。我注释了受影响区域中的所有测试,直到运行全部工作,然后将它们拉回来直到失败,然后看到我必须调试测试的实际SO异常。

Then I face palmed a few times and fixed it. Unlikely scenario, but you never know.

然后我面对几次并修好了。不太可能的情况,但你永远不知道。

#6


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)

在测试资源管理器(测试 - > Windows - >测试资源管理器)中,您可以看到所有跳过的测试。如果双击测试名称,它将打开实际的测试代码。检查测试是否具有[Ignore]属性,如果要运行测试,请将其删除。 (正如@Sridarshan建议的那样)

P.S. I had NUnit tests.

附:我有NUnit测试。