test.what.I.want target for NAnt
Allow me to introduce the test.what.I.want target. For this post I'm going to assume that you have or are using NAnt with MbUnit.
A special argument
The MbUnit application provides a very special argument called /filter-namespace. If you haven't guessed it yet this argument allows you to filter a suite of tests by a namespace.
| mbunit.cons.exe /filter-namespace |
An awesome target
The test.what.I.want target is very straight forward. The target first amalgamates the xunit.console.args property and the the namespace.to.test property into a single property called xunit.args. Next MbUnit.cons.exe is executed with the arguments supplied by the xunit.args property. The awesomeness of this target is categorized by its reusability.
<target name="test.what.I.want" depends="test.compile, test.copy.dependencies">
<property name="xunit.args" value="${xunit.console.args} /filter-namespace:${namespace.to.test} "/>
<exec basedir="${tools.dir}\mbunit\bin" useruntimeengine="true" workingdir="${build.dir}" failonerror="false" program="mbunit.Cons.exe" commandline="${xunit.args}" />
</target> |
The bat file
This is where the magic happens. In order to make our test.what.I.want target dynamic we need a way to override the namespace.to.test property. Thankfully, the Nant.exe allows you to supply an argument that can override the value of a property. This argument is simply called "D". "D" is my new best friend. His only purpose in life is to set the value for a given property and he does it like nobodies business. Taking advantage of D's sick skillz we can achieve a level of dynamicisim never thought of before. D will allow us to change the namespace.to.test property to any namespace space we desire to filter by.
typical build.bat| @echo off cls |
test.bat leverages build.bat
| build -D:namespace.to.test="%*" test.what.I.want |
Just incase you your new to bat files the %* is a placeholder for an argument.
An example using test.bat
| >test Ec.Aasp.OfflineTool.Test.DataAccess |
Expanding on this target
Now that you have this wicked little target, how can you take advantage of it.
- The first and most obvious benefit is that you can now test a single namespace on the fly at the command prompt. This comes in very handy when you want to test just one part of your project and you have not created an additional target.
- Using this new target you can easily create additional targets. For example, here is a target that I recently created to only test the domain.
<target name="test.domain" depends="test.compile, test.copy.dependencies">
<property name="namespace.to.test" value="Ec.Aasp.OfflineTool.Test.unit.Domain" />
<call target="test.what.I.want" />
</target>
- Why not create more bat files. Lets face it, reduced key strokes equals increased productivity. Instead of typing "build test.domain" why not type "domain" or "test.domain". With our new test.bat file we can eliminate creating additional targets in our NAnt script. We can eliminate the test.domain target by leveraging the test.bat file.
domain.bat leveraging test.battest Ec.Aasp.OfflineTool.Test.Unit.Domain
From the command prompt just type:
>domain
Your creativity does not have to be limited to C# or your programming language of choice. NAnt, batch files, SQL, etc are all venues and opportunities where you can flex your creative muscles.
8 comments:
And in Gallio you can create arbitrary composite filters like:
(Type:SomeTest or Namespace:TestWhatIWant, AndThisOtherThingToo or Name:/Foo.*IsARegex/) and not Name:SkipThisOne
That's awesome, now I don't have to run so many unit tests and slow down my TDD roll and hold that train of thought until the test results come in...
Good Post
That's awesome Jeff. I can't wait to give it a try.
miley cyrus nude [url=http://www.pyzam.com/profile/3311871]miley cyrus nude[/url] miley cyrus nude [url=http://educationorb.com/dias/user/view.php?id=3529&course=1]miley cyrus nude[/url]
Hi
[URL=http://blog.bakililar.az/Botshark/]Buy Tramadol Online[/URL]
Hi
[URL=http://blog.bakililar.az/Botshark/]Buy Tramadol Online[/URL]
dating services comparisons [url=http://loveepicentre.com/]russian dating site for sale[/url] athletic fit singles http://loveepicentre.com/ india meet singles
dual screen auto dvd player [url=http://www.cardvdplanet.com/car-video-dvd-player-single-din-7-inch--discount-price83.html]cathedral city auto audio products[/url] videovisor auto dvd visor http://www.cardvdplanet.com/4-3-inch-touchscreen-car-dvd-sd-card-reader--discount-price41.html oem car audio ford taurus
auto dvd video [url=http://www.cardvdplanet.com/9-0-inch-roof-mounting-dvd-player-fm-with-tv--discount-price69.html]d mercedes benz reviews auto extended warranty car audio and[/url] jvc auto audio manuals http://www.cardvdplanet.com/7-inch-touch-screen-build-in-gps-bluetooth-fold--discount-price101.html d mercedes benz reviews auto extended warranty car audio and
auto audio capasiters [url=http://www.cardvdplanet.com/15-inch-tft-lcd-touchscreen-dvd-with-vga--discount-price99.html]car audio for subaru legacy[/url] kansas city auto audio http://www.cardvdplanet.com/car-dvd-with-fmam-bluetooth-player-discount-price94.html car audio systems integrated ford falcon
Post a Comment