简体   繁体   English

在进行Jenkins构建时,如何忽略某个类别的NUnit测试?

[英]How can I ignore NUnit tests of a certain category while doing a Jenkins build?

How can I ignore NUnit tests of a certain category while doing a Jenkins build? 在进行Jenkins构建时,如何忽略某个类别的NUnit测试? I know how to do this in Team City. 我知道如何在Team City中这样做。 Our production environment uses Jenkins whilst our developers use Team City. 我们的生产环境使用Jenkins,而我们的开发人员使用Team City。 I need some tests (database integration) to be ignored while doing our production build on Jenkins. 我需要在Jenkins上进行生产构建时忽略一些测试(数据库集成)。 Any links, tips, or code are certainly appreciated. 任何链接,提示或代码当然值得赞赏。

[Test, Category("DBExclude")]
public void WidgetRepository_FindById_ReturnsWidget()
{
   //I should not run on Jenkins
}

Thanks All! 谢谢大家!

If you are using a Windows Batch command to execute the NUnit tests as part of the Jenkins job, you may simply use the command-line option "/exclude" on the category you've assigned to the test. 如果您使用Windows批处理命令作为Jenkins作业的一部分执行NUnit测试,则可以在已分配给测试的类别上使用命令行选项“/ exclude”。 For the example you've given, the command would be something akin to... 对于你给出的例子,命令将类似于......

nunit-console /exclude:DBExclude nunit.tests.dll

And, just for the record, you can do it the other way and select to run tests WITH a certain category as opposed to only those WITHOUT by using the following (again, making use of your example): 并且,只是为了记录,你可以用另一种方式做,并选择运行某个类别的测试而不是只有那些没有使用以下(再次,利用你的例子):

nunit-console /include:DBExclude nunit.tests.dll

NUnit has documentation that details these options and more here: NUnit Documentation NUnit提供了详细说明这些选项的文档以及更多内容: NUnit文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM