A simple tip to exclude certain tests from running during your automated build.
In this scenario we have a bunch of tests inside of a particular DLL. Inside of these tests we have a folder that is for “integration tests”. These tests are run usually once a day in a nightly build and are also run on a developers machine to ensure they didn’t break anything from an integration standpoint before checking in the code.
What we want to do is exclude the tests from running in our CC.NET continuous integration build environment. This is real simple to do by just following a couple of simple steps.
- Categorize your tests as “Integration” (or whatever you want to call them). I prefer “integration” because it signifies exactly what they are.
- Exclude them via the NUnit2 task in the NAnt build script.
Example code:
[TestFixture, Category("Integration")] public class OrderServiceIntegraitonTests { // a slew of tests go here ... }
Then in your NAnt file do something similar to the following to ensure these tests are excluded for the continuous integration build:
<nunit2 failonerror="true" > <formatter type="Xml" outputdir="${results.dir}" usefile="true" extension=".xml"/> <formatter type="${outputType}" usefile="false"/> <test assemblyname="${out.dir}/DF.Example.Tests.dll"> <categories> <exclude name="Integration" /> </categories> </test> </nunit2>
That’s it. By using the exclude element in the NUnit2 task in NAnt you can exclude them.
This is also a command line switch as well, so if you’re not running them in NAnt you can also exclude them via the command line switch, /exclude.
Leave a Reply
You must be logged in to post a comment.