Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? I know how to do this in Team City. Our production environment uses Jenkins whilst our developers use Team City. I need some tests (database integration) to be ignored while doing our production build on 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!

like image 744
Hcabnettek Avatar asked Jun 07 '12 17:06

Hcabnettek


1 Answers

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

like image 91
OmniSECT Avatar answered Oct 10 '22 01:10

OmniSECT