Affected Tests Docs

The --explain output

./gradlew affectedTest --explain

--explain prints the full decision trace without running a test: the bucket counts, the situation, the action, and which tier of the priority ladder (an explicit onXxx setting or the mode default) decided each action. Use it when a CI run escalated to the full suite and you need to know why before filing a bug. The playground shows the same output for any change you pick.

Text trace

This is the real output when a @Configuration class changed in a project with the default settings, run locally:

=== Affected Tests — decision trace (--explain) ===
Base ref:        origin/master
Mode:            LOCAL (effective: LOCAL)
Changed files:   1
Buckets:
  ignored         0
  out-of-scope    0
  production      1
  test            0
  unmapped        0
  production sample: notifications/src/main/java/com/acme/shop/notifications/NotificationsRateLimitConfig.java
Situation:       SPRING_CONFIG_CHANGED
Action:          FULL_SUITE (source: mode default)
Outcome:         FULL_SUITE — Spring application / configuration class changed — see the Spring escalation block
Spring escalation:
  notifications/src/main/java/com/acme/shop/notifications/NotificationsRateLimitConfig.java — @Configuration → onConfigurationClassChanged = full_suite
Action matrix (situation → action [source]):
  EMPTY_DIFF               SKIPPED [mode default]
  ALL_FILES_IGNORED        SKIPPED [mode default]
  ALL_FILES_OUT_OF_SCOPE   SKIPPED [mode default]
  UNMAPPED_FILE            FULL_SUITE [mode default]
  SPRING_CONFIG_CHANGED    FULL_SUITE [mode default]
  DISCOVERY_INCOMPLETE     SELECTED [mode default]
  DISCOVERY_EMPTY          SKIPPED [mode default]
  DISCOVERY_SUCCESS        SELECTED [explicit onXxx setting]
=== end --explain ===

Depending on the run, the trace also contains a per-strategy timing block, a Header edges block that lists every edge the headerEdges strategy followed or muted, and Hint: lines.

A hint appears when outOfScopeTestDirs or outOfScopeSourceDirs is configured but no file in the diff landed in the out-of-scope bucket, and the situation is DISCOVERY_SUCCESS or DISCOVERY_EMPTY. That is the silent-failure trap: a valid-looking glob that never matches, which would otherwise surface only after a long full-suite CI run. The hint is suppressed for EMPTY_DIFF, ALL_FILES_IGNORED, ALL_FILES_OUT_OF_SCOPE and UNMAPPED_FILE, because an out-of-scope pattern could not have influenced those.

JSON output

./gradlew affectedTest --explain --explain-format=json

This prints the same decision trace as a single-line JSON object at lifecycle level, for dashboards and telemetry pipelines that would otherwise have to parse the text. Text stays the default. Switching format never invalidates a Gradle cached execution, because --explain-format only changes logging.

Here is the real output for a change to a service implementation, pretty-printed:

{
  "version": 4,
  "baseRef": "origin/master",
  "mode": {"configured": "LOCAL", "effective": "LOCAL"},
  "changedFiles": 1,
  "buckets": {"ignored": 0, "outOfScope": 0, "production": 1, "test": 0, "unmapped": 0},
  "samples": {
    "production": ["payments/src/main/java/com/acme/shop/payments/DefaultFraudService.java"]
  },
  "situation": "DISCOVERY_SUCCESS",
  "action": {"name": "SELECTED", "source": "EXPLICIT"},
  "outcome": {"kind": "SELECTED", "selectedClassCount": 2, "escalationReason": "NONE"},
  "modules": [
    {
      "task": ":payments:test",
      "fqns": [
        "com.acme.shop.payments.DefaultFraudServiceTest",
        "com.acme.shop.payments.FraudServiceITTest"
      ]
    }
  ],
  "discovery": {
    "parallelEnabled": true,
    "concurrencyLevel": 4,
    "totalMillis": 120,
    "perStrategy": [
      {"name": "naming", "millis": 0, "tests": 2},
      {"name": "usage", "millis": 119, "tests": 2},
      {"name": "impl", "millis": 119, "tests": 1},
      {"name": "transitive", "millis": 14, "tests": 0}
    ]
  },
  "headerEdges": {
    "added": 2,
    "suppressed": 0,
    "suppressedFqns": [],
    "edges": [
      {
        "source": "com.acme.shop.payments.DefaultFraudService",
        "target": "com.acme.shop.payments.FraudService",
        "targetName": "FraudService",
        "category": "implements",
        "status": "ADDED"
      },
      {
        "source": "com.acme.shop.payments.DefaultFraudService",
        "target": "org.springframework.stereotype.Service",
        "targetName": "Service",
        "category": "annotations",
        "status": "IGNORED_BY_GLOB",
        "ignoreGlob": "org.springframework.**"
      }
    ]
  },
  "springEscalation": {"effect": "OFF", "triggers": []},
  "actionMatrix": {
    "EMPTY_DIFF": {"action": "SKIPPED", "source": "MODE_DEFAULT"},
    "ALL_FILES_IGNORED": {"action": "SKIPPED", "source": "MODE_DEFAULT"},
    "ALL_FILES_OUT_OF_SCOPE": {"action": "SKIPPED", "source": "MODE_DEFAULT"},
    "UNMAPPED_FILE": {"action": "FULL_SUITE", "source": "MODE_DEFAULT"},
    "SPRING_CONFIG_CHANGED": {"action": "FULL_SUITE", "source": "MODE_DEFAULT"},
    "DISCOVERY_INCOMPLETE": {"action": "SELECTED", "source": "MODE_DEFAULT"},
    "DISCOVERY_EMPTY": {"action": "SKIPPED", "source": "MODE_DEFAULT"},
    "DISCOVERY_SUCCESS": {"action": "SELECTED", "source": "EXPLICIT"}
  }
}

Schema history

New fields are added within a version. The version bumps when a field is renamed, removed or retyped.

VersionChange
1Initial schema.
2Added the discovery block (parallel-strategy timing, issue #76).
3Added the headerEdges block (issue #132).
4Added the springEscalation block (issue #133).

Fields

FieldTypeNotes
versionintThe schema version.
baseRefstringThe git ref the diff was computed against.
modeobjectconfigured is what the build declared (AUTO, LOCAL, CI or STRICT). effective is what AUTO resolved to on this run.
changedFilesintTotal diff size across every bucket.
bucketsobjectFive integer counts: ignored, outOfScope, production, test, unmapped.
samplesobjectUp to 10 sorted file names per bucket, the same cap as the text trace. Empty buckets are omitted. Compare a sample's length with buckets[X] to detect truncation.
situationstringOne of the eight situations.
actionobjectname is SELECTED, FULL_SUITE or SKIPPED. source is MODE_DEFAULT or EXPLICIT, the tier that resolved it.
outcomeobjectkind mirrors action.name. selectedClassCount is meaningful on SELECTED runs and 0 elsewhere. escalationReason is the same value the text trace shows on its Outcome: line.
modulesarrayOne entry per dispatched test task, with its Gradle task path in task and the full class list in fqns, never truncated. Empty when the outcome is not SELECTED.
discoveryobjectWhether discovery ran in parallel, its thread count, the total time, and perStrategy timings with the number of tests each strategy found.
headerEdgesobjectHow many types the strategy added or suppressed, and up to 10 edges with their category and status (ADDED, IGNORED_BY_GLOB, IGNORED_BY_CATEGORY, UNRESOLVED or SKIPPED_SIBLING_CAP).
springEscalationobjecteffect is OFF, INTEGRATION_TESTS or FULL_SUITE. triggers lists each file, the annotation that matched, the setting that decided it and that setting's effect.
actionMatrixobjectEvery situation mapped to its {action, source} pair. A test pins this, so a new situation cannot be added without updating the renderer.