The Test Runner tab opens in the Run tool window when a testing session begins, and features the same toolbar buttons.


Click thumbnail to view larger image.

  1. The progress bar shows the percentage of tests executed so far.
  2. The color of the status bar indicates whether the tests have passed successfully. If at least one of the tests fails, the status bar turns red.
  3. The left-hand pane shows the tree view of all tests within the current run/debug configuration.
    • The root node represents the test case selected to run.
    • The nested nodes represent the hierarchy of test suites and test cases.
    • The leaf nodes represent the individual tests.
    The status of each test is indicated by an icon. Double-click a node to open the respective test class or test method in the editor.
  4. The testing toolbar provides controls that enable you to monitor the tests and analyze results. Some of the commands are duplicated on the context menus of the test tree nodes and the entries in the Statistics pane.
  5. The Output pane shows the output of the current test suit.
  6. The Statistics pane shows the list of executed tests, with the time spent for each one, and the test result.

Run toolbar

ItemTooltip and ShortcutDescription
rerun Rerun
Ctrl+F5
Click this button to rerun the current process.

The process reruns always in the same console regardless of whether this console is pinned or not.

rerunFailedTests.png Rerun Failed TestsClick this button to have PyCharm execute all the tests that failed.
icon_toggleAutoTest Toggle auto-testIf this button is pressed, the autotest-like runner is turned on. It means that the test in the current run configuration tab will automatically rerun on changing its source code. Otherwise, to rerun such test, you have to click the rerun button rerun.
pauseIcon Pause OutputClick this button to have the process output paused.
stop Stop
Ctrl+F2
Click this button to terminate the current process externally by means of the standard mechanisms.
debug_layout.gif LayoutClick this button to choose a layout of the toolbars by selecting the desired option from the pop-up menu.
pin2.png PinWhen this button is pressed, the current tab will not be overwritten; instead, the results of the next command will be displayed in a new tab.
close.png Ctrl+Shift+F4 Click this button to close the selected tab of the Run tool window and terminate the current process.
help.gif F1 Click this button to show reference.

Testing toolbar

ItemTooltip and ShortcutDescription
junitHidePassedIcon.png Hide PassedPress this button, to have PyCharm show only the failed tests or the tests that encountered problems in the left-hand pane. If this button is not pressed, all tests are displayed in the tree view.
sortAlphabetically Sort alphabeticallyClick this button to sort tests in alphabetical order.
expandAll.png collapseAll Expand All/Collapse All
Ctrl+Add or Ctrl+EqualsCtrl+Subtract or Ctrl+Minus
Click these buttons to have all nodes in the tree view of tests expanded.

These buttons are only available if the tested application contains more than test case.

arrowUp.png arrowDown.png Previous/Next Failed Test
Ctrl+Alt+Up/Ctrl+Alt+Down
Click this button to navigate between the failed tests.
exportToTextFile.png Export Test ResultsClick this button to have the results of the selected test saved in a file.
projectToolWindowSettingsIcon.png Click this cog button to access the context menu with the following options:
  • Track Running Test - select this option to monitor execution of the current test. If a test suite contains multiple tests, the tree view of tests expands to show sequential test methods, as they are executed.
  • Select First Failed Test When Finished - select this option to have the first failed test automatically selected in the tree view upon completing the tests.
  • Scroll to Stacktrace - select this option to have the console scroll to the beginning of the trace of the last failed test.
    If the option is not selected and you click the root node (the test package) in the tree view, the console will show the very beginning of the test.

    This option is helpful when a test package contains multiple test classes and test methods. If some of the tests fail, you can scroll in the console to the beginning of a stack trace of an exception or assertion.

  • Autoscroll to Source - select this option to have the currently selected test in the tree view synchronized with the editor automatically.
  • Open Source at Exception - use this option to explore the results of a test that fails as an error, throwing an uncaught exception.
    If this option is selected and you double-click the failed test class or method in the tree view, the respective test class or method will open in the editor, with the caret placed at the line that caused the problem.
  • Show Statistics - select this option to have the Statistics pane opened, displaying a list of executed tests with the time used for executing each test and the test result.

Test status icons

IconDescription
testError.png Test error.
testFailed.png Test failed.
testIgnored.png Test ignored.
testInProgress1.png Test in progress.
testPassed.png Test passed successfully.
testPaused.png Test paused.
testTerminated.png Test terminated.
testNotRan.png Test not run.

Output pane

This pane shows output of each test, generated at runtime, including all the messages sent to the output stream, and the error messages. The following table shows the toolbar buttons and context menu commands available for the Output pane.

ItemKeyboard ShortcutDescription
arrowUp Up the Stack Trace
Ctrl+Alt+Up
Click this button to navigate up in the stack trace and have the cursor jump to the corresponding location in the source code.
arrowDown Down the Stack Trace
Ctrl+Alt+Down
Click this button to navigate down in the stack trace and have the cursor jump to the corresponding location in the source code.
icon_softWrap Use Soft Wraps Click this button to toggle the soft wrap mode of the output.
scrollToEnd.png Scroll to the end Click this button to navigate to the bottom of the stack trace and have the cursor jump to the corresponding location in the source code.
clear_allClear AllClick this button to have all messages for the selected test deleted from the Output console.
printPrintClick this button to send text from the output console to the default printer.

Context menu of the Output pane

ItemIconDescription
Compare with ClipboardChoose this item on the context menu to invoke theDifferences Viewer which shows the current contents of the Clipboard in the left-hand pane and the contents of the Output pane for the selected test in the right-hand pane. pane.
Create GistgistChoose this command to create a Git Gist.
Clear Allclear_allChoose this item on the context menu to have all messages for the selected test deleted.

Statistics pane

This pane shows how long it took to execute a test suite and the number of passed and failed tests within it.
By default, the Statistics pane is hidden. To show it, select click the cogwheel button projectToolWindowSettingsIcon.png, and select the check command Show Statistics. The pane shows a list of all the tests in the selected suit.

To view statistics on each test separately, choose Show Statistics on the respective test.

Column nameDescription
TestName of the test class or test method.
Time elapsedThe number of seconds spent to to execute this test.
ResultsThis column shows summary information about the test execution results. For individual tests, the column shows the pass or fail status. For test case or test suites, the column shows the number of failed and passed tests within it.

Context menu of the Statistics pane

CommandKeyboard shortcutDescription
Select <test name>Choose this command to select run/debug configuration of the current test in the run/debug configuration selector.
Save <test name>Choose this command to save the current temporary run/debug configuration as permanent.
Create <test name> Create a run/debug configuration on the base of the selected test.
Run <test name> Ctrl+Shift+F10 Run the selected test with the current temporary run/debug configuration.
Debug <test name>Debug the selected test with the current temporary run/debug configuration.
Run <test name> with Coverage runWithCoverage Run the selected test with coverage.
Jump to Source F4 Choose this command to move the focus to the editor, to the definition of a test class, or test method.
Show Source Ctrl+Enter Choose this command to open source code in the editor, but leave the focus with the Test Runner tab.
Navigate to TestChoose this command to jump to the tree-view of tests.

See Also

Procedures:

Reference:

Web Resources: