ReSharper Web Help

ReSharper provides Unit Test Explorer for viewing tests and arranging test sessions, and the Unit Test Sessions window for running test sessions and viewing test results. So, with ReSharper you can:

Run and debug tests

To run tests from Unit Test Explorer
  1. Make sure that your project has been built. Otherwise, ReSharper will not be able to populate Unit Test Explorer with the list of test fixtures that it contains.
  2. Open the Unit Test Explorer window. To do that, do one of the following:
    • On the main menu, choose ReSharper | Unit Tests | Unit Tests.
    • On the main menu, choose ReSharper | Windows | Unit Tests.
    • Press Ctrl+Alt+T.
  3. Select test(s) that you want to run:

  4. Click one of the following buttons in the Unit Test Explorer toolbar:
    • Run Selected Tests to run selected tests in the currently active session of the Unit Test Sessions window.
    • Append Selected Tests to Session to include selected tests into the session tab that is currently active in the Unit Test Sessions window, without running them right away.
    • New Session with Selected Tests to create a new session in the Unit Test Sessions window containing the selected tests, without running them right away.
  5. Depending on which command you have chosen in the previous step, selected tests display or run in the Unit Test Sessions window:

To run tests from the text editor, File Structure or Solution Explorer
  1. Open a class in the editor or select a test in File Structure, or select a node (project or solution node) in the Solution Explorer.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Unit Tests | Run Unit Tests.
    • Right-click, then click Run Unit Tests on the context menu.
    • Press Ctrl+T,R.
    The Unit Test Sessions window opens when you start running tests.
To debug tests from the text editor, File Structure or Solution Explorer
  1. Open a class in the editor or select a test in File Structure, or select a node (project or solution node) in Solution Explorer.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Unit Tests | Debug Unit Tests.
    • Right-click, then click Debug Unit Tests on the context menu.
    • Press Ctrl+T,D.
    The Unit Test Sessions window opens when you start debugging tests.

 Note

When tests are run or debugged from the editor, the caret position defines which test or tests are be involved. If the caret is inside a test method, that single test is run or debugged. If it is outside any test method, the entire test class contained in the current file is run or debugged.
To run or debug an individual test using side bar marks
  1. In the editor, open a class that contains unit tests.
  2. Click a side bar mark in the gutter.
  3. On the context menu, click Run or Debug to run or debug tests that the test class contains, or click Append to Session to include the tests into the specified (or a new) session in the Unit Test Sessions window (note that you can't add tests to a locked unit test session).

    Individual test marks let you run and debug a single test independently of other tests in the same class:

  4. A selected test or all tests in a class are run as a single session in the Unit Test Sessions window where you're able to review the test results.

Add tests to a session

To add tests to a new session
  • In the editor, click a side bar mark. On the context menu, click Append to Session, depending on your goal click Create New Session or click [session name].

  • In the Unit Test Explorer window, right-click a test to run, then click Create New Session or click [session name] on the context menu.

Quick unit test search

Starting with ReSharper 7.1 you can quickly filter unit tests in the Unit Test Session window. To do that, start typing text to be matched when the the Unit Test Session window is focused.

Lock a session

You can easily lock the active session, so all new tests will be run in a new session and can't be included in the locked one. To do that, click Lock Session on the toolbar of the Unit Test Sessions window.

Work with a group of tests

If you create automated tests, you probably use categories to simplify test management. You add test categories as attributes to your test methods or test classes.

The AspBlockCommentTest class has the Category attribute, and all test methods within the class belong to this category. So you can work with a particular test or a group of tests from the same category.

To run or debug a specific group of tests using side bar marks
  1. In the editor, open a class that contains unit tests.
  2. Click a side bar mark in the gutter.
  3. On the context menu, click Category "[category name]", then click Run or Debug depending on the goal.

Ignore a group of tests

To ignore a specific group of tests
  1. On the main menu, choose ReSharper | Options. The Options dialog box opens.
  2. Click the Unit Testing node in the left tab.
  3. In the Unit Testing tab, type names of categories that should be ignored in the Don't run tests from categories box.
  4. Click Save or Save To to apply changes.

ReSharper supports TestCase, TestCaseSource, Values and other attributes.

See Also

Procedures

Reference