How to tell Visual Studio Online VS Test Task to ignore certain nUnit test categories

被刻印的时光 ゝ 提交于 2019-12-07 12:46:13

问题


I am having a hard time telling Visual Studio Online to ignore certain tests I do not want to run during VSO build. I have one set of tests in my test library I do not want them to run during the online build process. Those tests might will take an extremelly long time to complete, so I do not want them to be part of the tests that will execute during the build phase, so the build agent takes as few minutes as possible to complete the build. So, I can mark those test with an NUnit category like this

/// <summary>
///     This is a long running test
/// </summary>
[Test]
[Category("LongRunningTest")]
public void ObtainsTourInformationTest() {
...
}

This is a partial capture of my test task definition. I read somewhere I could use the Test filter criteria for this purpose but I haven't figure it out.

I am using the following NUnit packages

<package id="NUnit.Runners" version="2.6.4" />  
<package id="NUnit" version="2.6.4"/>
<package id="NUnitTestAdapter" version="2.0.0" /> 

So, basically, what I need to know is how to tel Visual Studio Online Test Task to ignore tests marked with NUnit Category Attribute.


回答1:


"TestCategory!=LongRunningTest"

Alternatively, if working online in Visual Studio, group the tests by Traits and select only those you want to run.




回答2:


The other way to approach this is to put all the long running tests in a separate project and then either:

  • Exclude that specific project (as I have done with Membership.Business.LibraryCS.IntegrationTests.dll in the example below)
  • Or use a standard naming convention for projects that solely contain long running tests and then exclude all of those projects (as I have done for any project with 'endtoend' in its name in the example below)

Here's a screen grab of how we have that set up in Azure DevOps:

We find this particularly effective for end-to-end tests that hit the local DB and so don't work on DevOps. Putting them in their own project is ideal in that scenario as the end-to-end test project can have a connection string to the test database, whereas not having that connection in any of the unit test projects ensures they aren't accidentally hitting the database.



来源:https://stackoverflow.com/questions/42587063/how-to-tell-visual-studio-online-vs-test-task-to-ignore-certain-nunit-test-categ

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