This post originated from an RSS feed registered with Agile Buzz
by Jared Richardson.
Original Post: MBUnit for .NET testing
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog.
The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
A co-worker of mine (Susan Bartholow) mentioned a neat feature in MBUnit today and I thought it was share-worthy. :)
First, what is MBUnit? MBUnit is a .NET testing framework. You can use it for testing any of the .NET family of languages. C#, VB, etc. Here's a short tutorial.
Remember, a testing framework with "unit" in the
name isn't just useful for unit testing! ;) The
various XUnit frameworks
are great for functional and integration tests as well.
Second, Susan's tip about the decorator. (A decorator is a feature added to the test framework.) She found a decorator in MBUnit called ThreadedRepeat.
Here's a short description of ThreadedRepeat from the Peli's Farm blog
In MbUnit, other decorators are available. Here I describe two of those:
RepeatAttribute and ThreadedRepeatAttribute. RepeatAttribute will make the
execution of the test repeated the desired number of times in the same thread
while ThreadedRepeatAttribute will launch simultaneously a desired number of
threads that will execute the method. RepeatAttribute create a sequence of
execution, ThreadedRepeatAttribute create a parallel execution.
[Test]
[Repeat(10)] // this will make the RepeatedTest executed 10 times
public void RepeatedTest()
{ ... }
[Test]
[ThreadedRepeat(10)] // this will make the RepeatedTest executed in 10 concurent threads
public void AmIThreadSake()
{ ... }
This is a quick decorator that can help get you started with some basic threaded testing. You can simulate multiple users or a heavier load. It's a great way to leverage your existing test suites. Talk about code re-use! :)