Shaun Abram
Technology and Leadership Blog
Running tests in IntelliJ for a multi module maven project
This post shows how to run all the tests in IntelliJ for a multi module maven project.
- From the menu, select Run -> Edit Configurations…
- Select + Add New Configuration -> JUnit
- In the “Run/Debug Configurations” dialog, specify:
- Name: up to you e.g. All Tests
- Test Kind: All in package
- Package: leave empty
- Search for tests: In whole project
- VM Options: leave as is, typically -ea
- Working directory: Specify the project’s root directory. By default this seems to be $MODULE_DIR$, but I found leaving it as this resulted in this error when I ran the tests with coverage:
Error running All Tests:
‘Run with Coverage’ is disabled when per-module working directory is configured.
Please specify single working directory, or change test scope to single module.
You can now click the Run With Coverage button.
I find it best to view the Code Coverage (View -> Tool Windows -> Coverage) with Flatten Packages selected.
See related links:
- StackOverflow: Run unit tests in IntelliJ IDEA from multiple modules together
- IntelliJ run-debug-configuration
- IntelliJ Configuring Code Coverage
- IntelliJ Code Coverage
Tags: intellij, Maven, mvn, Testing