Issue while running individual unit test cases in multiple modules in IntelliJ

Facing the following issue:

Project ‘xyz’ not found in root project 'all’

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

while running individual unit test cases in IntelliJ IDEA.

Please explain the whole situation, or better attach a test project demonstrating the problem.

We have five modules in our application and in each module, we have unit test cases and these test cases run only via gradle task build.gradle. If we try to run each individual test case using the run button in IntelliJ we get the above error.

Try to make sure your add-on subprojects have the same name in Gradle as their subdirectories.

For example, if you have the following composite project structure:

all/
    build.gradle
    settings.gradle
users/
    users/
    users-starter/
    build.gradle
    settings.gradle

And in all/settings.gradle:

rootProject.name = 'all'

includeBuild '../users'
// ...

Then in users/settings.gradle you should set the project name as follows:

rootProject.name = 'users'

Then IntelliJ test runner will form the gradle task name correctly.

Alternatively, you can change it in the Run/Debug Configuration of the test:
image

1 Like