How-To's

New Features in ReSharper 6 Unit Test Runner

Previous posts introducing ReSharper 6:

ReSharper 6 includes a series of new features and improvements in the test runner, as outlined below.

NUnit TestCase

We now fully support NUnit’s TestCase, TestCaseSource, Values, Ranges and other attributes. Given the following tests:

image

ReSharper outputs the results as individual tests, appropriately grouped.

image

This allows us to now run and view tests individually.

image

As expected, dotCover and dotTrace also provide support for this.

Support for Coded UI Tests with MSTest

Coded UI tests (when appropriate) are also supported now with the ReSharper test runner

image

Default Keyboard Bindings and Test Re-Runs

Out of the box ReSharper now ships with pre-defined shortcut keys for running, debugging, re-running tests, among other things. This eases the pain of having to map keys on new installations (as of ReSharper 6, you no longer loose your key bindings during upgrades!). By default, the key-bindings for the schemes are:

Operation Visual Studio IntelliJ IDEA
Run Unit Tests. Context Sensitive Ctrl+U, R Ctrl+T, R
Debug Unit Tests. Context Sensitive Ctrl+U, D Ctrl+T, D
Run ALL Unit Tests Ctrl+U, L Ctrl+T, L
Run Current Session Ctrl+U, Y Ctrl+T, Y
Rerun last test. Context Insensitiveimage Ctrl+U, U Ctrl+T, T

This last shortcut is a new feature added in 6 which allows us to re-run the last test we just ran. And we can run it from anywhere! This makes TDD for instance very easy as we can write some code, be in the actual code and run the test, without having to switch back to the test or open up the unit text explorer.

Running Tests from File Structure and Find Results Windows

You can now run Tests directly from the File Structure Window

SNAGHTML14c0e0a

as well as the Find Results Window

SNAGHTML14d0b1d

again, removing some of the friction when it comes to testing.

Categories

Certain Unit Testing frameworks provide test categories. For example, in NUnit there is the [Category] attribute. ReSharper now allows us to ignore specific categories and not run them during a test run. This is accomplished by indicating the category under ReSharper | Options | Unit Testing

image

When running unit tests, these appear as ignored.

image

This is useful for instance when we want to avoid running certain tests during development sessions.

Categories can also be used to run a specific group of tests by selecting these from the context menus:

image

Other improvements

Some other minor improvement or previous features we have blogged about include:

  • QUnit Support
  • Unit testing Sessions are now persisted between Visual Studio restarts
  • Ability to run tests in parallel from different assemblies, decreasing testing time (can be turned off in ReSharper | Options | Unit Testing)
  • General performance improvements
  • Update Progress indicator on Windows task bar

image

As always, we welcome your feedback

image description