Rerun and debug tests
You can repeat a test session or individual tests without leaving the Run tool window. The tests are performed again using the same run configuration as in the initial run.
Press CtrlF5 or click the Rerun button on the toolbar of Test Runner tab .
Note that you can rerun the tests automatically.
In the Test Runner tab , right-click a test case node or a test and select Run <test_target>.
In the Test Runner tab , click the Rerun Failed Tests button on the toolbar.
PyCharm lets you rerun run/debug configuration of a test automatically, if the source code has been changed. To enable autotest-like runner facility, make sure that the Rerun Automatically button in the Run toolbar of the Test Runner tab is pressed.
Press the Rerun Automatically button on the Run toolbar of the Test Runner tab.
For Mocha and Jest, add the
--watch
flag in the Extra Mocha options/Extra Jest options field of the Run/Debug Configuration: Mocha or Run/Debug Configuration: Jest dialog respectively.
When one or several tests in your test suite failed, debugging can help you quickly inspect the failures, preview the problematic code lines in the editor, and fix them.
Open the project Settings (CtrlAlt0S). Go to Build, Execution, Deployment | Python Debugger and select the Drop into debugger on failed tests checkbox.
Open the test file in the editor. Right-click it and select the Debug <test name>.
PyCharm stops on every failed test and shows the reason for the failure. Inspect the Variables pane of the Debugger tool window to get more details about the problems.
Use the debugging toolbar to step through the test code.
note
The debugger also stops at test set up and tear down functions if they contain any errors (for example,
setUp
andtearDown
for Unittest and pytest fixtures).If you discovered and fixed the problems, you can just click the Run icon () in the gutter and terminate the debugging process.
You can also select a particular failed test in the Run tool window and debug it separately.
Thanks for your feedback!