May 182011
 

 

I am working in a large WPF project that is in a continuous evolution. Initially when we started the project we didn’t have any kind of unit testing in mind, then later we switched to an (almost) TDD approach. Since we use TFS for source control and automated builds, the natural decision was to use MSUnit as the test framework. Although this approach has some benefits, after the project has grown in size we have reached several limitations.

Just to name a few (disclaimer: I don’t want to turn this post in a flame war between MSUnit vs NUnit – I always think that you have to use the right tool for the right job):

  • the integrated test runner is slow… too slow to be able to do TDD in a reasonable timely fashion
  • lack of support for test input parameters (I know you can use databases to specify input parameters, but I find that setting up a database just to test 5 parameter combinations is a way too big overhead)
  • the limited (and naïve) support for test inheritance

I find the last point to be one of the most problematic limitations on large scale projects that use inheritance extensively. We’ve found several workarounds, none of which make your life easier – from duplicating similar test code to making a base class (which must be testable by itself – which increases the complexity of the tests significantly) to using T4 templates for generating similar tests. None of this approaches are really good solutions since they all increase the maintenance time and the complexity and footprint of the test code.

So in the end, after several discussions, we have decided to try to switch from MSUnit to NUnit. This blog is the first one in a series that covers this transition touching all important aspects of such a transition:

  1. Tools
  2. Migrating test code
  3. Integration with TFS builds
  4. Code coverage

 Transitioning from MSUnit to NUnit

  • Pingback: The Morning Brew - Chris Alcock » The Morning Brew #855

  • http://www.lybecker.com/blog/ Anders Lybecker

    Hi Sebastian,

    Can you elaborate on the last point ”the limited (and naïve) support for test inheritance”?
    Excuse my ignorance as I have almost no experience working with MSTest.

    • Sebastian Negomireanu

      Hi Anders, MSUnit supports inheriting a test class from a base test class, but with some limitations: you cannot use an abstract base class, nor a generic one. Also, when running tests, it will run the base test class as a standalone test. This is fine if the classes that you test are all concrete. But if you have an abstract base class, then you would probably also have an abstract base test class, which is not possible using MSUnit.

      I hope this clarifies things a bit.

  • http://www.lybecker.com/blog/ Anders Lybecker

    Thanks for the clarification.

    Years ago when I last used MSTest I recall something about the build-in MSTest runner is able to run unit tests i parallel and therefore speeding up the execution on multi-core computers.

  • http://blog.excastle.com/ Joe White

    Nice info! The links in this post are broken, though. If you remove the “index.php/####/##/##/” part, then they’re fine.

    • http://www.byteflux.me byteflux

      Thank you. I have fixed the links, they should be working fine now.