ReSharper 2016.3 Help

Working with Unit Tests in Current Document

In this topic:

Discovering Tests in the current document

ReSharper discovers unit test classs and single unit tests of all supported frameworks right in the editor and adds the corresponding action indicators next to each item in the editor:

ReSharper shows different indicators for unit tests in the editor

... and in the File Structure window:

ReSharper shows unit tests in File Structure
  • /help/img/dotnet/2016.3/ThemedIcon.UnitTestingOptionsPage.Screen.[Gray].png - the method is a unit test and you can run and debug it.
  • /help/img/dotnet/2016.3/ThemedIcon.UnitSession.Screen.[Gray].png - the class is a unit test class and you can run and debug containing tests.
  • /help/img/dotnet/2016.3/ThemedIcon.TestMethodSuccess.Screen.[Gray].png - the unit test passed during the last execution.
  • /help/img/dotnet/2016.3/ThemedIcon.TestFixtureSuccess.Screen.[Gray].png - tests in the unit test class passed during the last execution.
  • /help/img/dotnet/2016.3/ThemedIcon.TestMethodFail.Screen.[Gray].png - the unit test failed during the last execution.
  • /help/img/dotnet/2016.3/ThemedIcon.TestFixtureFail.Screen.[Gray].png - at least one test in the unit test class failed during the last execution.
  • /help/img/dotnet/2016.3/ThemedIcon.TestMethodIgnored.Screen.[Gray].png - the unit test was ignored during the last execution.
  • /help/img/dotnet/2016.3/ThemedIcon.TestFixtureIgnored.Screen.[Gray].png - all tests in the unit test class were ignored during the last execution.

Running and debugging tests in the current document

There are several ways to run or debug unit tests in the current document. You can use action indicators, main menu or shortcuts:

  • To run or debug a single test or all tests in a test class, click on the action indicator next to it or set the caret on the test /test class and press Alt+Enter . In the action list , choose Run / Debug for a test or Run All /Debug All for a test class.
    /help/img/dotnet/2016.3/Unit_Testing__Recognizing_Unit_Tests__test_fixture.png
  • Alternatively, you can use the Run Unit Tests / Debug Unit Tests commands, which are available in the main menu (ReSharper | Unit Tests), in the context menu or with Ctrl+T,R / Ctrl+T,D shortcuts correspondingly. These commands work differently depending on the caret position or selection in the editor:
    • To run or debug a single test or all tests in a test class , set the caret at the test /test class name or anywhere inside it in the editor or select it in the File Structure window .
    • To run several tests, select the desired tests in the editor or in the File Structure window .
    • To run all tests in the current file, either select all or set the caret outside test classs.

Whatever way you choose to run or debug tests, you will see the execution progress, results and output in the Unit Test Sessions window. If there is an open unit test session, the executed tests are added in this session. If there are no test sessions or the existing ones are locked, then a new tests session is created.

If necessary, you can always re-run the tests that you executed last by choosing ReSharper | Unit Tests | Repeat Previous Run in the menu or pressing Ctrl+T,T.

Last modified: 20 January 2017