RSS Feed Subscribe to RSS Feed

 

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.

  1. From the menu, select Run -> Edit Configurations…
  2. Select + Add New Configuration -> JUnit
  3. 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:

Tags: , , ,

Leave a Reply