...
To enable this functionality for Gradle or IntelliJ IDEA project runners simply turn on "Run affected tests only (dependency based)" checkbox.
Maven
For Maven it's a bit more complicated. It's called "Incremental building" and has some additional settings. When incremental building is on, a Maven build is splitted into two phases - the preparation phase and the main phase - both separate Maven executions. The "main" phase is like a regular (not incremental) build in which main goals ("test", "verify", etc.) are executed with the only difference - they are executed only for modules affected by changes. The "preparation" phase is intended for building the dependecies of affected modules. Unfortunately these two phases couldn't be accomplished in a single Maven execution. Why is to be explained in detail later in a separate blog post. Before that it's quite easy to remember the following pattern:
...