To enable this functionality for Gradle or IntelliJ IDEA project runners simply turn on "Run affected tests only (dependency based)" checkbox. In case of Maven, some additional settings are available: TODO.
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:
- if your tests are executed with the goal "test", then the preparation goal is "compile" (unless you have custom executions required for tests in affected modules and bound to later Maven lifecycle phases).
- if you run both unit and integration tests with "verify", then the preparation goal is "package" (with the same considerations described above) with additional Maven argument "-Dmaven.test.skip=true" to avoid executing unit tests in the preparation phase.
This TeamCity EAP build comes with bundled NuGet Support plugin. We already announced availability of this plugin in a series of blog posts: