Affected Tests Docs

Migrating from v1

v2.0.0 removed three v1 settings. If any of them still appears in your build.gradle, Gradle configuration fails before the affectedTest task runs:

  • runAllIfNoMatches
  • runAllOnNonJavaChange
  • excludePaths

Since v2.1.0 the error names the exact replacement. For example, runAllIfNoMatches = false now fails with:

> affectedTests.runAllIfNoMatches was removed in v2.0.0. Use
  onEmptyDiff = "full_suite" and/or onDiscoveryEmpty = "full_suite"
  instead (or set mode = "ci" / "strict" to get those defaults). See
  CHANGELOG.md v2.0 for the full migration table.

Kotlin DSL builds get a compile error that names the removed property.

Deprecation timeline

ReleaseWhat happened
v1.9.x and earlierThe legacy settings worked silently.
v1.10.x to v1.11.xThey still worked, and a per-run WARNING: [affected-tests] '<knob>' is deprecated… named each one and its replacement.
v2.0.0The legacy settings were removed. They are unknown properties and Gradle configuration fails.

Before and after

v1 settingv2 equivalentWhy
runAllIfNoMatches = trueonEmptyDiff = "full_suite" and onDiscoveryEmpty = "full_suite"The v1 flag mixed two situations: an empty diff and a discovery that found nothing. v2 separates them.
runAllIfNoMatches = falsemode = "local", or pin onEmptyDiff = "skipped" and onDiscoveryEmpty = "skipped"Do not just delete the line. In v2 the default mode = "auto" resolves to ci in a CI runner, and ci runs the full suite for DISCOVERY_EMPTY. A pipeline that set this to false to avoid that would start running everything on every no-match change.
runAllOnNonJavaChange = trueonUnmappedFile = "full_suite"The same behaviour, and it is the default.
runAllOnNonJavaChange = falseonUnmappedFile = "selected"The unmapped file is treated as absent and discovery continues.
excludePaths = ["**/generated/**"]ignorePaths = ["**/generated/**"]A rename with the same meaning. Setting ignorePaths replaces its default list, so see the defaults.
excludePaths = []Delete the lineThe v2 default list is broader (markdown, text, licence, changelog, images, generated). An explicit empty list discards all of it.

Worked example

Before (v1):

affectedTests {
    baseRef = "origin/master"
    runAllIfNoMatches = true
    runAllOnNonJavaChange = true
    excludePaths = ["**/generated/**"]
    transitiveDepth = 4
}

After (v2):

affectedTests {
    baseRef = "origin/master"
    mode = "ci"
}

mode = "ci" replaces both booleans in most cases. The default ignorePaths already covers generated/, and transitiveDepth = 4 is now the default.

If you want every situation spelled out, which suits production pipelines where each edge case matters:

affectedTests {
    baseRef = "origin/master"
    onEmptyDiff          = "full_suite"
    onAllFilesIgnored    = "skipped"
    onAllFilesOutOfScope = "skipped"
    onUnmappedFile       = "full_suite"
    onDiscoveryEmpty     = "full_suite"
}

Alerting on the summary line

Every run prints one summary line with the outcome, the situation and the v2 setting that fired:

Affected Tests: FULL_SUITE (UNMAPPED_FILE) — 1 changed file(s); running full suite (onUnmappedFile=FULL_SUITE — non-Java or unmapped file in diff).

v1 summary lines carried both the v1 name (runAllOnNonJavaChange=true) and the v2 name to ease migration. v2 dropped the v1 names. Alert rules that match runAllIfNoMatches=true, runAllOnNonJavaChange=true or the [affected-tests] '…' is deprecated warning must move to the v2 names. See the decision model for the vocabulary.