Configuration
Every setting has a default. Override only what you need, in the affectedTests block of the build.gradle that applies the plugin:
affectedTests {
baseRef = "origin/main"
outOfScopeTestDirs = ["e2e-tests/**"]
onConfigurationClassChanged = "integration_tests"
}
In the Kotlin DSL, assign with .set(...), for example baseRef.set("origin/main") and outOfScopeTestDirs.set(listOf("e2e-tests/**")).
You can see each of these settings change a real selection in the playground.
Diff
| Setting | Default | What it does |
|---|---|---|
baseRef | "origin/master" | The git ref to diff against. Also settable with -PaffectedTestsBaseRef=<ref>. If it cannot be resolved the build fails, so a CI run never silently skips tests. |
includeUncommitted | false | Add uncommitted changes to the diff. The default is committed-only, so a local run matches the diff CI will see on the same HEAD and gives the same selection however your working tree looks. Turn it on locally while iterating; leave it off in CI. |
includeStaged | false | Add staged changes to the diff. Same guidance as includeUncommitted. |
Mode and per-situation actions
| Setting | Default | What it does |
|---|---|---|
mode | unset, which means "auto" | "auto", "local", "ci" or "strict". Seeds the default action for every situation. Also settable with -PaffectedTestsMode=<mode>. See mode profiles. |
onEmptyDiff | from mode | Action when the diff is empty. |
onAllFilesIgnored | from mode | Action when every file matched ignorePaths. |
onAllFilesOutOfScope | from mode | Action when every file is out of scope. |
onUnmappedFile | "full_suite" in every mode | Action when the diff holds a file that does not map to a Java class. This is the safety knob for merge requests. Set "selected" to treat such files as absent and continue to discovery. |
onDiscoveryEmpty | from mode | Action when discovery finds no tests. |
onDiscoveryIncomplete | from mode | Action when a scanned file failed to parse. |
Each onXxx setting takes "selected", "full_suite" or "skipped". An explicit value always beats the mode default.
Path buckets
| Setting | Default | What it does |
|---|---|---|
ignorePaths | **/generated/**, *.md, *.txt, LICENSE, LICENSE.*, CHANGELOG* and *.png, *.jpg, *.jpeg, *.svg, *.gif (each also as **/… for nested paths) | Files that must not influence selection. A diff made only of these is ALL_FILES_IGNORED. Setting this replaces the defaults, so copy the ones you still want. |
outOfScopeTestDirs | [] | Test source sets that affectedTest never dispatches, such as Cucumber or Gatling modules. A diff entirely under them is ALL_FILES_OUT_OF_SCOPE. |
outOfScopeSourceDirs | [] | Production source sets to treat as out of scope. Same pattern shapes as above. |
outOfScopeTestDirs and outOfScopeSourceDirs accept two kinds of entry, and you can mix them:
- Literal directory prefixes.
"api-test/src/test/java"matches that path at the repository root or under any module, such asservices/orders/api-test/src/test/java/...."api-test"never claims a sibling likeapi-test-utils/.... - Ant-style globs.
"api-test/**"or"**/api-test/**", using the standard JVM glob syntax (*,**,?,[abc],{a,b}).
If you set one of these but --explain prints a Hint: saying no file matched, your pattern does not bite. Check it: a valid-looking glob that matches nothing is easy to write and would otherwise show up only after a full-suite CI run.
Discovery
| Setting | Default | What it does |
|---|---|---|
strategies | ["naming", "usage", "impl", "transitive", "headerEdges"] | The strategies to run. See how it works. |
transitiveDepth | 4 | How many levels the transitive strategy walks. Clamped to 0 to 5; 0 turns the strategy off. |
testSuffixes | ["Test", "IT", "ITTest", "IntegrationTest"] | Suffixes the naming strategy tries for a class. |
includeImplementationTests | true | Also select tests for implementations of a changed interface. |
implementationNaming | ["Impl", "Default"] | Prefixes and suffixes that mark an implementation: Impl matches FooImpl for Foo, Default matches DefaultFoo. |
parallelDiscovery | true | Run the strategies on a small thread pool. Also settable with -PaffectedTestsParallelDiscovery=false. |
kotlinEnabled | true | Parse .kt files. Set false to fall back to path-based mapping for Kotlin. |
Source and test directories
| Setting | Default | What it does |
|---|---|---|
sourceDirs | Read from the Java plugin's source sets, falling back to ["src/main/java"] | Production directories. An explicit list always wins over auto-discovery. |
testDirs | Read from the Java plugin's source sets, falling back to ["src/test/java"] | Test directories. Any source set with a Test task is included, including custom names like integrationTest. |
testTaskNames | ["test"] | Gradle test tasks the dispatcher may call. If you add integrationTest, make sure its directory is in testDirs so discovery can see those tests. |
Header edges
These tune the headerEdges strategy. See how it works for what it does.
| Setting | Default | What it does |
|---|---|---|
headerEdgesEnabled | true | Kill switch for the strategy. |
headerEdgesExclude | [] | Categories to turn off: "extends", "implements", "permits", "type-bounds", "record-components", "annotations". Turning off "annotations" is the usual choice for code with many custom class-level annotations that carry no test-relevant behaviour. |
headerEdgesDepth | 1 | How many hops to follow. Clamped to 0 to 2; higher values approach a full suite on real code, and 0 is the kill switch. |
headerEdgesMaxSiblings | 5 | When a header-added type has more than this many direct subtypes, the downward walk from it is suppressed. This stops a base class with 52 subclasses from selecting every controller test. 0 suppresses every such walk. |
headerEdgesIgnore | JDK (java.lang, java.util, java.io, java.time, java.math, java.nio, java.text), javax, jakarta, Spring, JUnit, Mockito, Lombok, Kotlin and groovy.lang globs | Fully qualified name globs whose header edges are muted. Setting this replaces the defaults, so concatenate with them if you only want to add one. |
Spring escalation
These settings decide what a changed Spring class adds to the selection. Spring and @Bean changes explains the reasoning.
| Setting | Default | What it does |
|---|---|---|
onApplicationClassChanged | "full_suite" | Effect when a changed class carries an application annotation. "full_suite", "integration_tests" or "off". |
onConfigurationClassChanged | "full_suite" | Effect when a changed class carries a configuration annotation. Same values. |
applicationAnnotations | ["SpringBootApplication"] | Annotations that mark an application entry point, matched by simple name. |
configurationAnnotations | ["Configuration", "SpringBootConfiguration", "ConfigurationProperties"] | Annotations that mark a configuration class, matched by simple name. |
integrationTestPatterns | ["**/*IT", "**/*ITTest", "**/*IntegrationTest"] | Globs over the test class name, with dots read as /, that define an integration test. |
Execution
| Setting | Default | What it does |
|---|---|---|
gradlewTimeoutSeconds | 0 (no timeout) | Wall-clock limit for the nested ./gradlew :module:test call. On timeout it terminates the child and fails the build. A negative value is rejected at configuration time, so a typo is caught by ./gradlew help. |
A fuller example
affectedTests {
baseRef = "origin/main"
mode = "auto"
outOfScopeTestDirs = ["e2e-tests/**", "performance-test/**"]
onUnmappedFile = "full_suite"
onDiscoveryEmpty = "full_suite"
onDiscoveryIncomplete = "full_suite"
onApplicationClassChanged = "full_suite"
onConfigurationClassChanged = "integration_tests"
transitiveDepth = 4
testTaskNames = ["test", "integrationTest"]
testDirs = ["src/test/java", "src/integrationTest/java"]
gradlewTimeoutSeconds = 3600
}