Jump to navigation

Poupou's Corner of the Web

Looking for perfect security? Try a wireless brick.
Otherwise you may find some unperfect stuff here...

Weblog

Google Code In / Gendarme - Special Report #2

Running Gendarme on unit tests assemblies does not seem very productive and it's not something I ever did before. However I did, more than once, some stupid mistakes that prevented all unit tests from being executed. What better solution that having a few rules specific to unit tests ?

Introducing Gendarme.Rules.NUnit.dll. A new set of speciality rules (i.e. not enabled in the default rule set) that provided a few good tasks for Google Code In students (well one student actually :-). Currently it consist of three simple rules to avoid the (well my) most common pitfalls when writing unit tests:

  • Having [Test] attributes on non-public methods, which never gets executed;
  • Missing [TestFixture] on types - this is "fixed" in NUnit 2.5 but Mono is still using (internally) the older 2.4 release;
  • Assert.* calls without a message, making them harder to find in source (even more if your stack trace is inexact)
Gendarme provides, for itself, a new target 'make check-test' to run those rules on it's own unit test (and yes a few defects were fixed ;-). It should be easy to copy/paste into your own project - even easier if you already integrated a Gendarme step into your build.

So did you ever got bite by other things while doing your unit testing ? If that can be turned into a rule then please come chat with us on #gendarme!


12/16/2010 08:37:23 | Comments

The views expressed on this website/weblog are mine alone and do not necessarily reflect the views of my employer.