Run Python tests

Last modified: 29 November 2022

Generally, IntelliJ IDEA runs and debugs Python tests in the same way as other Python applications, by running the run/debug configurations you have created. When doing so, it passes the specified test classes or methods to the test runner.

In many cases, you can initiate a testing session from a context menu. For this purpose, the Run and Debug commands are provided in certain context menus. For example, these commands are available for a test class, directory, or a package in the Project tool window. They are also available for a test class or method you are currently working on in the editor.

If you run a test for which there is no permanent run/debug configuration, a temporary configuration is created. You can then save such a configuration using the Run/debug configuration dialog if you want to reuse it later.

The tests run in the background, so you can execute several tests at the same time.

Each running configuration gets its own tab in the Run tool window (the Test Results tab). One tab can aggregate several tests.

See Run tests for more details on running tests in IntelliJ IDEA.

By default, all tests are executed one by one. You can change this behavior for the pytest testing framework and execute your tests in parallel.

If you can stop a running tests, all running tests stop immediately. Icons of tests in the Run tool window reflect status of the test (passed, failed, aborted).