Unit Testing Improvements in ReSharper 7

The ReSharper unit test runner has become an indispensable part of ReSharper. The ability to run and debug tests from a location in code, together with an integrated unit test runner make testing with ReSharper a streamlined and pleasant experience, and a rich variety of plug-ins supporting many popular unit test frameworks makes ReSharper relevant whatever unit testing framework you choose.

Here is an overview of some of the new unit testing features that we are shipping in ReSharper 7.

Jasmine Support

The previous version of ReSharper has shipped with support for the QUnit JavaScript test framework. In this release, we have added support for Jasmine — a behavior-driven development framework for testing JavaScript code:

Naturally, just like any other type of unit tests, Jasmine tests are presented in the ReSharper unit test runner:

PhantomJS Test Runner

In addition to being able to run QUnit and Jasmine tests in a browser, ReSharper 7 offers an alternative mechanism: one can use PhantomJS – a command-line interface to WebKit – to run JavaScript unit tests instead. To start using it, download and unpack PhantomJS, then open up ReSharper options (the Unit Testing|JavaScript Tests tab) and specify the install location:

Now, any all JavaScript tests will be executed in a PhantomJS environment. Since a full browser is not needed for the tests, ReSharper will not open up a summary page inside a web browser.

NUnit Improvements

The new version of ReSharper comes with support for the TestCaseSource attribute. This attribute lets test authors define external variables that store test data. For example:

Since the argument to the attribute references a variable by name, ReSharper comes with appropriate inspections…

…as well as code completion:

As of this release, ReSharper supports NUnit version 2.6 by default.

Support for Other Frameworks

If you are looking for a test framework that isn’t supported by ReSharper out of the box, don’t worry – many plugin authors have already prepared the corresponding ReSharper plug-ins. Frameworks supported by ReSharper plugins today include AgUnit, Gallio/MbUnit, MSpec, and XUnit.

That’s it — happy coding! (And testing, of course.)

Discover more