Essential c# unit testing tools
During the last 6 years, I’ve preached unit testing to my colleagues and people attending my test-driven development courses. The set of tools I’ve used for this purpose have been stable, for the most part. This blog post is an attempt to create a snapshot of the tools and frameworks I’m using right now.
Unit-Test Framework and Runner
NUnit has been my preferred tool to execute tests. I did some fooling around with MSTest a couple of years ago, but unlike NUnit, you need to install Visual Studio on the build server to run the tests. The syntax is strange and the test runner for Visual studio sucks. I also looked at xUnit.net which is cool, but the limited support for ReSharper at the time kept me from switching. Let’s admit it: NUnit is the defacto standard these days. The support and community around NUnit is so great, that I will probably not switch anytime soon. I really hope that NUnit looks into the cool things happening in xUnit.net. I also hope that build servers, Visual Studio extensions and other tools integrating unit test frameworks will do a better job of integrating xUnit.net.
Rhino Mocks has been my favorite mocking framework for years. I tried Moq two years ago, but quickly switched back to Rhino Mocks due to the strange errors I was receiving from Moq. Last year, I tried Moq again and liked it so much that this is now my favorite mocking framework. I also tried FakeItEasy, but I didn’t really think that it brought anything new to the table.
You might be thinking something like, “Whuuut? Why does the unit-test freak suddenly mention anything about build servers, in the middle of a blog post about unit-testing tools?” Well, without a build server to execute all of your unit-tests, you probably shouldn’t write them in the first place. The build server is a perfect place for conducting regression testing. I typically run all of my unit-tests before committing code, letting the build server run the heavy database-dependent integration-tests. During the last 10 years as a professional software developer, I’ve tried practically all major build servers from homemade bat-scripts over CruiseControl and CruiseControl.NET to TeamCity. TeamCity is my current favorite, with great support for .NET/C#.
Any opinions on missing frameworks?