# Run tests

> **TL;DR**
> Run the selected test or test folder: `Ctrl+Shift+F10` (Windows), `⌃ ⇧ R` (macOS), `⌃ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ R` (macOS System Shortcuts), `Ctrl+Shift+F10` (XWin), `Ctrl+Shift+F10` (GNOME), `Ctrl+Shift+F10` (KDE), `Ctrl+Shift+F10` (Emacs), `Ctrl+Shift+F10` (Sublime Text), `Ctrl+Shift+F10` (Sublime Text (macOS)), `Alt+Shift+F6` (NetBeans), `Ctrl+Alt+F5` (Visual Studio), `⌃ ⌥ F5` (Visual Studio (macOS)), `Ctrl+Shift+F10` (Eclipse), `⌃ ⇧ R` (Eclipse (macOS))
>
>
>
> Stop the current test session: `Ctrl+F2` (Windows), `⌘ F2` (macOS), `⌘ F2` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ .` (macOS System Shortcuts), `Ctrl+F2` (XWin), `Ctrl+F2` (GNOME), `Ctrl+2` (KDE), `Ctrl+F2` (Emacs), `Ctrl+F2` (Sublime Text), `Ctrl+F2` (Sublime Text (macOS)), `Shift+F5` (NetBeans), `Shift+F5` (Visual Studio), `⇧ F5` (Visual Studio (macOS)), `Ctrl+F2` (Eclipse), `⌘ F2` (Eclipse (macOS))

IntelliJ IDEA provides actions that let you run, rerun, and debug your tests. You can invoke these actions from different places in the IDE depending on the scope you want to test:

* [Editor](#run-tests): a single test or test class.

* [Structure tool window](#run_tests_from_structure): one or more tests from a single test class.

* [Project tool window](#run-tests): all tests under a directory or package.

* [Run widget](#run-with-options): tests that match the criteria specified in the run configuration.

* [Commit tool window](#run_tests_from_commit_tw): test classes that have uncommitted changes.

> **Note:**
> This topic explains how to run tests using dedicated actions in IntelliJ IDEA. If you are looking for information on how to run tests using a specific build tool, refer to the following topics:
>
>
>
> * [Testing in Maven projects](work-with-tests-in-maven.html)
>
> * [Testing in Gradle projects](work-with-tests-in-gradle.html)

Procedure: Run tests directly in a file or folder

If your tests do not require any specific actions before start, and you do not want to configure additional options,  such as [code coverage](code-coverage.html) ,  you can run them by using the following options:

* Place the caret at the test class to run all tests in that class, or at the test method, and press `Ctrl+Shift+F10` (Windows), `⌃ ⇧ R` (macOS), `⌃ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ R` (macOS System Shortcuts), `Ctrl+Shift+F10` (XWin), `Ctrl+Shift+F10` (GNOME), `Ctrl+Shift+F10` (KDE), `Ctrl+Shift+F10` (Emacs), `Ctrl+Shift+F10` (Sublime Text), `Ctrl+Shift+F10` (Sublime Text (macOS)), `Alt+Shift+F6` (NetBeans), `Ctrl+Alt+F5` (Visual Studio), `⌃ ⌥ F5` (Visual Studio (macOS)), `Ctrl+Shift+F10` (Eclipse), `⌃ ⇧ R` (Eclipse (macOS)). Alternatively, click the ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) gutter icon next to the test class or test method and select Run '<test name>' from the list.

The gutter icon changes depending on the state of your test:

* The ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.actions.runAll.svg) gutter icon marks a set of tests.

* The ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) gutter icon marks new tests.

* The ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.gutter.runSuccess.svg) gutter icon marks successful tests.

* The ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.gutter.runError.svg) gutter icon marks failed tests.

![Running a test using the gutter icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-test.png)

* To run all tests in a folder, select this folder in the Project tool window and press `Ctrl+Shift+F10` (Windows), `⌃ ⇧ R` (macOS), `⌃ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ R` (macOS System Shortcuts), `Ctrl+Shift+F10` (XWin), `Ctrl+Shift+F10` (GNOME), `Ctrl+Shift+F10` (KDE), `Ctrl+Shift+F10` (Emacs), `Ctrl+Shift+F10` (Sublime Text), `Ctrl+Shift+F10` (Sublime Text (macOS)), `Alt+Shift+F6` (NetBeans), `Ctrl+Alt+F5` (Visual Studio), `⌃ ⌥ F5` (Visual Studio (macOS)), `Ctrl+Shift+F10` (Eclipse), `⌃ ⇧ R` (Eclipse (macOS)) or select Run Tests in 'folder' from the context menu.

Procedure: Run tests using the Run widget

When you run a test, IntelliJ IDEA creates a temporary run configuration. You can save temporary run configurations, change their settings, share them with other members of your team. For more information, refer to [Run/debug configurations](run-debug-configuration.html).

1. Create a new [run configuration](run-debug-configuration.html) or save a temporary one.

2. Use the Run widget on the main toolbar to select the configuration you want to run.

3. Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) or press `Shift+F10` (Windows), `⌃ R` (macOS), `⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ R` (macOS System Shortcuts), `Shift+F10` (XWin), `Shift+F10` (GNOME), `Shift+F10` (KDE), `Shift+F10` (Emacs), `Shift+F10` (Sublime Text), `Shift+F10` (Sublime Text (macOS)), `F6` (NetBeans), `Ctrl+F5` (Visual Studio), `⌃ F5` (Visual Studio (macOS)), `Alt+Shift+X` (Eclipse), `⌘ ⇧ F11` (Eclipse (macOS)).

![Running a run/debug configuration for tests](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-run-config-tests.png)

Procedure: Run tests from Structure

In the [Structure tool window](viewing-structure-of-a-source-file.html#structure-tool-window), you can select one or several test methods in a class to run. In this case, the IDE also creates a temporary run configuration with these methods that you can [save](run-debug-configuration.html#save-as-permanent) and edit.

1. In the Structure tool window, right-click one or several test methods and select ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.gutter.run.svg) Run 'method name' (`Ctrl+Shift+F10` (Windows), `⌃ ⇧ R` (macOS), `⌃ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ R` (macOS System Shortcuts), `Ctrl+Shift+F10` (XWin), `Ctrl+Shift+F10` (GNOME), `Ctrl+Shift+F10` (KDE), `Ctrl+Shift+F10` (Emacs), `Ctrl+Shift+F10` (Sublime Text), `Ctrl+Shift+F10` (Sublime Text (macOS)), `Alt+Shift+F6` (NetBeans), `Ctrl+Alt+F5` (Visual Studio), `⌃ ⌥ F5` (Visual Studio (macOS)), `Ctrl+Shift+F10` (Eclipse), `⌃ ⇧ R` (Eclipse (macOS))).

![Run code from the tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-from-structure2.png)

The tool window allows you to add test methods to an existing run configuration (for JUnit and TestNG tests) in which the test scope is specified by means of a [pattern](run-debug-configuration-junit.html#testKind). You can add methods from several different classes creating a test suite.

2. Right-click a method in the Structure tool window and select:

* Add to temp suite: <Configuration_name> if there is only one configuration with the Pattern test scope.

* Add to JUnit Pattern Suite (JUnit) / Add to Temp Suite (TestNG) if there are several configurations with the Pattern test scope. In this case, a popup appears in which you can select the target configuration.

![Run code from the tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-from-structure.png)

Procedure: Run tests from the Commit tool window

If you made changes to your test classes and want to run them before committing, you can do it from the [Commit tool
window](commit-and-push-changes.html#commit). You can choose whether to run a single test class, multiple classes, or all uncommitted test classes under a directory, module, or changelist.

1. Go to the Commit tool window (`Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS))).

2. Right-click a test class, directory, module, or changelist, and select ![Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) Run '<Test Class Name>'.

> **Tip:**
> To select multiple items, hold `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (NetBeans), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) while clicking each item.

![Run action in the context menu of the Commit tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-test-from-commit-tw.png)

As a result, IntelliJ IDEA creates and launches a temporary run configuration for your test selection. If you want to rerun the same tests in the future, you can [save this
configuration](run-debug-configuration.html#save-as-permanent) in the run widget and then [customize
its settings](list-of-run-debug-configurations.html).

> **Tip:**
> To preserve the tab of a run configuration, even if you execute another run configuration, [you may pin it](run-tool-window.html#pin_tabs).

After IntelliJ IDEA finishes running your tests, it shows the results in the Run tool window on the tab for that run configuration. For more information about analyzing test results, refer to [Explore test results](viewing-and-exploring-test-results.html).

![Tests shows in run configuration tab](https://resources.jetbrains.com.cn/help/img/idea/2026.2/tests-in-run-configuration-tab.png)

The console on the right shows the output of the current test session. The test results toolbar located above the list of test results provides you with several helpful options.

![the test results toolbar](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_testResultsToolbar.png)

## Run tests after commit

When you want to check that your changes would not break the code before pushing them, you can do that by running tests as commit checks.

> **Note:**
> This feature is only available for [Git](using-git-integration.html) and [Mercurial](using-mercurial-integration.html).

Procedure: Set up test configuration

1. Press `Alt+0` (Windows), `⌘ 0` (macOS), `⌘ 0` (IntelliJ IDEA Classic (macOS)), `⌘ 0` (macOS System Shortcuts), `Alt+0` (XWin), `Alt+0` (GNOME), `Alt+0` (KDE), `Alt+0` (Emacs), `Alt+0` (Sublime Text), `⌘ 0` (Sublime Text (macOS)), `Alt+0` (NetBeans), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (Eclipse), `⌘ 0` (Eclipse (macOS)) to open the Commit tool window and click Show Commit Options ![the Settings button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.settings.svg).

2. Under the Advanced Commit Checks menu, next to the Run Configuration option, click  Choose configuration  and select which configuration  you want to run. This can be a test configuration provided by your build tool, for example, `gradle test` or a single test class from the project.

![Pre-commit checks menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run-tests-before-commit-0.png)

After you have set up the test configuration, the specified tests will run every time you make a commit.

## Stop tests

Procedure:

Use the following options on the test results toolbar  of the tab for the run configuration:

* Click ![the Stop button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.stop.svg) or press `Ctrl+F2` (Windows), `⌘ F2` (macOS), `⌘ F2` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ .` (macOS System Shortcuts), `Ctrl+F2` (XWin), `Ctrl+F2` (GNOME), `Ctrl+2` (KDE), `Ctrl+F2` (Emacs), `Ctrl+F2` (Sublime Text), `Ctrl+F2` (Sublime Text (macOS)), `Shift+F5` (NetBeans), `Shift+F5` (Visual Studio), `⇧ F5` (Visual Studio (macOS)), `Ctrl+F2` (Eclipse), `⌘ F2` (Eclipse (macOS)) to terminate the process immediately.

![Stop running tests](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_stop_running_tests.png)

* Click ![the Exit button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.exit.svg) to terminate the process gracefully, allowing shutdown hooks to run.

![Terminate running tests gracefully](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_terminate_tests_gracefully.png)

## Rerun tests

Procedure: Rerun a single test

* Right-click a test on the tab for the run configuration in the Run tool window and select Run 'test name'.

![Rerun a single test](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rerun_one_test.png)

Procedure: Rerun all tests in a session

* Click ![the Rerun button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.run.rerun.svg) on the test results toolbar  or press `Ctrl+F5` (Windows), `⌘ R` (macOS), `⌃ F5` (IntelliJ IDEA Classic (macOS)), `⌘ R` (macOS System Shortcuts), `Ctrl+F5` (XWin), `Ctrl+F5` (GNOME), `Ctrl+5` (KDE), `Ctrl+F5` (Emacs), `Ctrl+F5` (Sublime Text), `⌘ R` (Sublime Text (macOS)), `Ctrl+F5` (NetBeans), `Ctrl+Alt+R` (Visual Studio), `⌘ ⌥ R` (Visual Studio (macOS)), `Ctrl+F5` (Eclipse), `Ctrl+F5` (Eclipse (macOS)) to rerun all tests in a session.

![Rerun all session tests](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rerun_all_tests.png)

Procedure: Rerun failed tests

* Click ![the Rerun Failed Tests icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.restartFailedTests.svg) on the test results toolbar  to rerun only failed tests.

![Rerun failed tests](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rerun_failed_tests.png)

Hold `Shift` (Windows), `Shift` (macOS), `Shift` (IntelliJ IDEA Classic (macOS)), `Shift` (macOS System Shortcuts), `Shift` (XWin), `Shift` (GNOME), `Shift` (KDE), `Shift` (Emacs), `Shift` (Sublime Text), `Shift` (Sublime Text (macOS)), `Shift` (NetBeans), `Shift` (Visual Studio), `Shift` (Visual Studio (macOS)), `Shift` (Eclipse), `Shift` (Eclipse (macOS)) and click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.restartFailedTests.svg) to choose whether you want to Run the failed tests again or Debug  them.

You can configure the IDE to trigger tests that were ignored or not started during the previous test run together with failed tests. Click ![the Settings button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.settings.svg) on the test results toolbar  and enable the Include Non-Started Tests into Rerun Failed option.

Procedure: Rerun tests automatically

In IntelliJ IDEA, you can enable the autotest-like runner: any test in the current run configuration restarts automatically after you change the related source code.

1. Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.actions.rerunAutomatically.svg) Rerun Automatically on the test results toolbar to enable the autotest-like runner.

![Rerun Automatically option](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_rerun_test_automatically.png)

2. Additionally, you can enable the auto-test popup in the editor. It indicates that the autotest-like runner is on. Click the ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.actions.more.svg) More icon on the toolbar and enable Show Auto-Test Status in the Editor.

The Auto-test on ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.actions.rerunAutomatically.svg) popup shows up in the editor if the autotest-like runner is enabled. Click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.actions.rerunAutomatically.svg) in the popup to disable the automatic rerunning of tests.

![Auto-test popup in editor](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ij_autotest_popup.png)

## Debug failed tests

If you do not know why a test fails, you can debug it.

Procedure:

1. In the editor, click the gutter on the line where you want to set a   breakpoint .

There are different types of breakpoints that you can use depending on where you want to suspend the program. For more information, refer to [Breakpoints](using-breakpoints.html).

2. Right-click the ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.gutter.runError.svg) gutter icon next to the failed test and select Debug 'test name'.

The test will rerun in debug mode. After that, the test will be suspended, allowing you to [examine its current state](examining-suspended-program.html).

You can [step through the test](stepping-through-the-program.html) to analyze its execution in detail.

![Debugging a test using the gutter icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/debug-test.png)

## See also

### Procedures

[Testing in Maven projects](work-with-tests-in-maven.html) [Testing in Gradle projects](work-with-tests-in-gradle.html) [Debugging code in IntelliJ IDEA](debugging-code.html)

### Reference

[Run tool window](run-tool-window.html)

