# Run, debug, terminate tests

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-clion.html),  you can run them by using the following options:

* Click the gutter icon next to the test or test suite/fixture.

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/cl_runtest_gutter.png)

Procedure: Run tests using the Run widget

1. Create a new [test configuration](unit-testing-tutorial.html#test-configurations) or [save](unit-testing-tutorial.html#run-from-gutter) 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)), `⌘ ⌥ ⇧ R` (Xcode), `Ctrl+F5` (Visual Studio), `⌃ F5` (Visual Studio (macOS)), `Ctrl+F5` (ReSharper), `⌃ F5` (ReSharper (macOS)), `Ctrl+R` (QtCreator), `⌘ R` (QtCreator (macOS)), `F6` (NetBeans), `Alt+Shift+X` (Eclipse), `⌘ ⇧ F11` (Eclipse (macOS)).

![Test configurations switcher](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_tests_configswticher.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)), `⌘ 0` (Xcode), `Alt+0` (Visual Studio), `Alt+0` (Visual Studio (macOS)), `Alt+0` (ReSharper), `Alt+0` (ReSharper (macOS)), `Alt+0` (QtCreator), `⌘ 0` (QtCreator (macOS)), `Alt+0` (NetBeans), `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` (Xcode), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (ReSharper), `Ctrl` (ReSharper (macOS)), `Ctrl` (QtCreator), `Ctrl` (QtCreator (macOS)), `Ctrl` (NetBeans), `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, CLion 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](null).

After CLion 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).

## Stop tests

Procedure:

Use the following options on the Run 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)), `⌘ .` (Xcode), `Shift+F5` (Visual Studio), `⇧ F5` (Visual Studio (macOS)), `Shift+F5` (ReSharper), `⇧ F5` (ReSharper (macOS)), `Shift+F5` (QtCreator), `⌘ ⇧ Y` (QtCreator (macOS)), `Shift+F5` (NetBeans), `Ctrl+F2` (Eclipse), `⌘ F2` (Eclipse (macOS)) to terminate the process immediately.

## 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'.

![Rerunning a test](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_tests_rerun_contextmenu.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 Run 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)), `⌘ R` (Xcode), `Ctrl+Alt+R` (Visual Studio), `⌘ ⌥ R` (Visual Studio (macOS)), `Ctrl+F5` (ReSharper), `Ctrl+F5` (ReSharper (macOS)), `Ctrl+F5` (QtCreator), `Ctrl+F5` (QtCreator (macOS)), `Ctrl+F5` (NetBeans), `Ctrl+F5` (Eclipse), `Ctrl+F5` (Eclipse (macOS)) to rerun all tests in a session.

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 Run toolbar to rerun only failed tests.

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` (Xcode), `Shift` (Visual Studio), `Shift` (Visual Studio (macOS)), `Shift` (ReSharper), `Shift` (ReSharper (macOS)), `Shift` (QtCreator), `Shift` (QtCreator (macOS)), `Shift` (NetBeans), `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 Run toolbar and enable the Include Non-Started Tests into Rerun Failed option.

> **Tip:**
> If you do not want the tests to rebuild on each rerun, select the test configuration in the Edit Configurations dialog and remove (![the Remove icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg)) Build from the Before launch block.

## Debug tests

Procedure:

1. In the editor, click the gutter on the line where you want to set a [breakpoint](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'.

![Debugging a failed test](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_debugfailedtest_gutter.png)

Alternatively, use the context menu of the test in the Test runner window:

![Test runner context menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_tests_runnercontextmenu.png)

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.

## See also

### Getting Started

[Unit testing tutorial](unit-testing-tutorial.html)

### How tos

[Explore test results](viewing-and-exploring-test-results.html)

