Unit Testing Succinctly: Unit Test Tools

This is an extract from the Unit Testing Succinctly eBook, by Marc Clifton, kindly provided by Syncfusion.

NUnit

NUnit was originally ported from JUnit as an open-source unit test engine providing a rich suite of test fixture, method, and variable attributes, as well as test assertions. The documentation for all versions of NUnit can be found here. NUnit is still being maintained. The latest stable release at the time of this writing is version 2.6.2, released on October 22, 2012.


CSUnit

CSUnit is a lighter-weight unit test engine. Note that it does not appear to be maintained, as the last release was in March 2009. It offers a minimal but functional set of attributes to use for defining test fixtures and test methods.


Visual Studio Test Project

Visual Studio provides the ability to create test projects directly in the IDE. One of the issues the author discovered is that the user interface has changed between VS 2008 and VS 2012:

Visual Studio 2008 Test Results UI

VS2008 Test Results UI
VS2008 Test Results UI

In VS2008, the test run executes very quickly and displays an easy-to-read list of test results and, for failed tests, the error message providing information as to why the test failed.

Also, when the test project is the active project, running the tests (or debugging them) is the same as with any other application—you can run them with Ctrl+F5 (run) or F5 (debug).

Visual Studio 2012 Test Results UI

VS2012 Test Results UI
VS2012 Test Results UI

In VS2012, the test runner takes several seconds to initialize. Worse, the messages associated with a test result are obtained by clicking on the failure. The additional click requirement is a significant usability issue. Because of the changes in how failures are displayed, Visual Studio 2008 has been used for screenshots throughout this book.

Lastly, the test runner is no longer initiated through the same shortcut keys as a regular application. Instead, the developer must use Ctrl+R, A to run the tests. There is no keyboard shortcut mapped to debugging the unit tests.

Visual Studio and NUnit Integration

Microsoft provides integration tools for NUnit for both Visual Studio 2010 (http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099) and 2012 (http://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d), though at the time of this writing, the Visual Studio 2012 NUnit test adapter is a beta 3-2.


Other Unit Test Tools

There are a few other test engines worth mentioning here.

MSTest

MSTest (http://msdn.microsoft.com/en-us/library/ms182489 is the command-line version of Microsoft’s test runner.

MbUnit/Gallio

MbUnit and Gallio are closely related. Gallio is a test automation platform allowing you to integrate a variety of test frameworks and reporting tools. This is a sophisticated tool that is worth exploring once you become familiar with unit testing principles and other engines.

Microsoft Test Manager

Microsoft Test Manager is a tool for planning, managing, and executing tests, either manually or automatically. Microsoft Test Manager integrates with bug tracking, allows writing notes associated with your tests, and allows you to configure virtual lab machines that can be reset to a known state before tests are run.

FsUnit

FsUnit is a test engine that facilitates working with the F# language.


Integration Testing Frameworks

Unit testing is designed to validate the correctness of computational code units. Integration testing is designed to test the behavior of the user interface.

NBehave

For readers familiar with Ruby, NBehave is an early prototype of features similar to Cucumber in that one writes behavioral tests. Tests are written in natural language, for example (both of these examples come from the GitHub NBehave website):

and methods implement the phrases (which can of course be re-used):

Keep in mind that this is not unit testing, rather, it facilitates a paradigm called Behavior-Driven Development and is mentioned here to illustrate other forms of testing that complement unit testing.

Tags:

Comments

Related Articles