ReSharper 2016.1 Help

Using Unit Test Sessions

ReSharper allows you to group unit tests that target specific part of your application into unit test sessions. A unit test session can contain tests of different supported frameworks, from different projects. You can have multiple test sessions and run them separately as needed. A single test /test class can be included into several different test sessions.

By default, unit test sessions are saved automatically for each solution; ReSharper keeps them even if you close and reopen the solution. If necessary, you choose not to keep unit test sessions by clearing the Save and restore Unit Test Sessions check-box on the Tools | Unit Testing options page.

In this topic:

Accessing unit test sessions

Unit test sessions management is done in the Unit Test Sessions Window. To open this window, choose ReSharper | Windows | Unit Test Sessions in the main menu or press Ctrl+Alt+R. The window opens automatically each time you run or debug unit tests from the current document or from the project/solution, create a new test session, or add tests to a test session.

All existing unit test sessions are displayed in tabs of the Unit Test Sessions window.

The Unit Test Sessions window also visualizes the test runner activity: it displays execution progress as well as status and output of the executed tests. Each time you run or debug tests they are either added to the current test session or a new unit test session is created for them.

Creating and closing unit test sessions

There are several ways to create a new test session:

  • Just run or debug unit tests from the current document or from the project/solution. If there are no test sessions or the existing sessions are locked, a new tests session with all executed tests is created. Otherwise, the tests are added to the currently opened session.
  • In the editor, click an action indicator next to a test or test class or set the caret at this item and press Alt+Enter , and then choose Create New Session in the action list. A new session with this test/test class will be created.
  • In the Unit Test Explorer Window, select tests/test classes for the new session and click Create New Session toolbar__new_session_with_selected_tests on the toolbar or press Ctrl+T,N.
  • In the main menu, choose ReSharper | Unit Tests | Create New Session or press Ctrl+T,N. If the focus is in the editor or in the Unit Test Explorer window and some tests/test classes are selected, or the caret is at or inside a test/test class, the new test session is created with the corresponding items. Otherwise, an empty test session is created.

If you want to prevent adding new tests to the session, you can lock it.

To close a unit test session, simply close the corresponding tab in the Unit Test Sessions window. The closed session will not be available anymore.

Adding and removing items in a test session

By default, if you run or debug tests that are not included into any session the tests are added to the current session.

If you want to prevent adding new tests to the session, you can lock it.

There are other ways to add tests/test classes to a session:

  • In the editor, click an action indicator next to a test or test class or set the caret at this item and press Alt+Enter , and then choose Append to [current session] in the action list. If you want to add the item to another section, click the small arrow next to this command and choose any of the existing test sessions in a sub-menu:
    Unit_Testing__Recognizing_Unit_Tests__append_01
    You can also choose ReSharper | Unit Tests | Append Tests to Session in the main menu or press Ctrl+T,A to add the selected items to a session.
  • In the Unit Test Explorer Window, select tests/test classes that you want to add and click Append Tests to Session ThemedIcon.AddedParameter.Screen.[Gray] on the toolbar or press Ctrl+T,A. If there are more than one session, choose the target session in the pop-up that appears.

To remove tests from the session, select the tests or grouping items that you want to remove and click Remove Selected Tests toolbar__remove on the toolbar.

Renaming test sessions

By default, the first test/test class that you add to a new test session is used as the session's name.

To rename a session, right-click on its tab in the Unit Test Sessions Window, choose Rename Session in the context menu or simply double-click the tab, and then specify a new name for the session in the appeared dialog.

Locking and unlocking unit tests sessions

By default, if you run or debug tests that are not included into any session the tests are added to the current session.

If necessary, you can prevent adding new tests to a session. To do so, in the Unit Test Sessions window switch to the tab of the session that you want to lock, click Options on the toolbar, and then select Lock Session uts_toolbar_lock_session.

To unlock the session, repeat the same actions.

Last modified: 19 August 2016