Sunday, October 19, 2014

.NET Unit Test Frameworks


Just a brief summary of some of the Unit Test Frameworks out there right now for C# and a basic summary of pros/cons of each.

XUnit.Net

  • Leanest and newest framework. It can be integrated into the IDE VS 2013 using http://www.testdriven.net/.
  • Unique, modern, and flexible approach to unit testing: very extensible, control over base methods (overrideable), fit-style testing directly out of the box,
  • Combines well with mocking framework, Moq for a very flexible, extensible, and powerful platform for implementing automated testing.
  • Very poor documentation.
  • Written by the original inventor of NUnit.

NUnit

  • Most standard and the first one created of the three.
  • It can also be integrated into the IDE VS 2013 using http://www.testdriven.net/.
  • NUNit has TestCaseSource attribute which helps you to achieve parametrized test cases but in MSTest you'll need DataSoruce which would be in xml file and will be difficult to manage when you have complex logic in method.
  • NUnit is faster as compare to MSTest.
  • NUnit has since added most of the attributes that XUnit has, but does not quite have as much flexibility.

MSTest

  • Only one with built in IDE integration and backed by Microsoft. The visual studio test-runner is slower than Testdriven.Net + NUnit or XUnit.
  • MSTest has no x64 support. Tests always run as x86.
  • Does not run standalone very well.
  • Strategy is targeted at many different styles of automated testing, including Integration Testing, System Testing, Performance Testing, but not specifically for unit testing, because it's too heavy to work with.