# Testing in Maven

In the Maven project, you can [create](create-tests.html) and [run](performing-tests.html) tests the same way you do in any other project using the [default IntelliJ IDEA test runner](delegate-build-and-run-actions-to-maven.html#delegate_to_maven).

Procedure: Run a simple JUnit test

1. Open your Maven project.

2. Create or open a test class in the editor and click ![the Run button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.runConfigurations.testState.run_run.svg) in the gutter to run it or select other options from the context menu such as ![the Run with Coverage option](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.run.runWithCoverage.svg) Run test with Coverage.

![Run test](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run_test_mvn.png)

The result is displayed in the Run tool window.

For more information about creating or running regular tests, refer to the [Testing](performing-tests.html) section.

You can [delegate](delegate-build-and-run-actions-to-maven.html#run_debug_with_maven) test execution to Maven.

You can also pass the [Maven Surefire plugin](http://maven.apache.org/surefire/maven-surefire-plugin/) parameters when you run JUnit or TestNg tests and the [Maven Failsafe plugin](http://maven.apache.org/surefire/maven-failsafe-plugin/) parameters for running integration tests. The Maven surefire plugin is declared in the super POM by default, but you can adjust its settings in your project's POM.

Procedure: Run tests

1. Open the Maven tool window.

2. Under the Lifecycle node, select test.

![the Maven tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_lifecycle_test_goal.png) Note that goals specified in the [Maven surefire plugin](http://maven.apache.org/surefire/maven-surefire-plugin/) will be activated at this phase and all tests in a project or in a module will be run.

Procedure: Run a single test

If you want to run a single test instead of all the tests declared in your project, create a Maven run configuration for a single test with the Maven `-Dtest=TestName test` command. The run configuration will be saved under the Run Configurations node.

1. In the Maven tool window, under the Lifecycle node, right-click the test goal.

2. From the context menu, select Modify Run Configuration.

3. In the dialog that opens, specify a working directory that contains test you want to run and in the Command line field, specify a phase (specified automatically) and the `-Dtest=TestName test` command.

![Run/Debug Configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_run_config_for_test.png) Click OK.

4. Open the Run Configurations node and double-click your configuration to run.

![the saved Run configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_saved_config.png) Maven runs the test and displays the result in the Run tool window.

Procedure: Skip tests

You can skip running tests, for example, when you want to just compile your project and don't want to wait for Maven to complete the tests' execution.

> **Tip:**
> The skip tests action in IntelliJ IDEA is an implementation of the `-DskipTests=true` Maven command.

1. Click the ![the Maven settings](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.settings.svg) icon in the Maven tool window to open `Maven` settings and select Runner from the options on the left.

> **Tip:**
> In the [Maven](maven-projects-tool-window.html) tool window, use ![Toggle Skip Test Mode](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.run.showIgnored.svg) to toggle the Skip tests mode.

2. On the Runner page, select Skip tests and click OK.

![the Maven settings | Runner](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_settings_skipTests.png) IntelliJ IDEA deactivates the test goal under the Lifecycle node.

![the Maven tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_tool_win_skipTest.png) The appropriate message notifying that tests are skipped is displayed in the Run tool window when you execute other goals.

![the Run tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/maven_run_tool_win_notify.png)

## Debug tests with Maven

You can debug tests executed by Maven. For example, if you want to debug tests running in a pipeline, then you can fork the process and debug it remotely using Maven commands.

For more information, refer to the [Maven documentation](https://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html) and the [remote debugging](tutorial-remote-debug.html) process.

Procedure: Debug tests

1. In your Maven project, open the Run/Debug Configurations dialog.

2. Add a new Remote JVM Debug configuration.

3. In the options on the right, add a name, change the port if needed (the default is `8000`), select the module classpath and click OK.

![Debug configurations](https://resources.jetbrains.com.cn/help/img/idea/2026.2/mvn_debug_config.png)

4. Set the [break points](using-breakpoints.html) where needed.

5. Press `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)) twice to open the [Run Anything](running-anything.html) window. Enter the [Maven command](https://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html#forked-tests) for forked tests. The default 5005 port is used for the process. However, you can change the port and run it on the local host with the following command:

```
mvn -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000" test
```

![Local terminal](https://resources.jetbrains.com.cn/help/img/idea/2026.2/local_teminal_mvnDebug.png)

You can check what other [Maven commands](https://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html#non-forked-tests) can be used. For example, what to use if you don't want to fork the debugging process.

You can check the running process in the Run tool window.

![Run tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/run_tool_window_mvn.png)

6. Start the debugging process, by clicking ![the Debug button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.startDebugger.svg) against the created debug configuration on the main toolbar.

Check the result in the Debug tool window.

![the Debug console tab](https://resources.jetbrains.com.cn/help/img/idea/2026.2/debug_console.png)

As the code executes, it will pause at the breakpoints you have set in your code.

