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.
| Version | Change |
|---|---|
| 1 | Initial schema. |
| 2 | Added the discovery block (parallel-strategy timing, issue #76). |
| 3 | Added the headerEdges block (issue #132). |
| 4 | Added the springEscalation block (issue #133). |
Fields
| Field | Type | Notes |
|---|---|---|
version | int | The schema version. |
baseRef | string | The git ref the diff was computed against. |
mode | object | configured is what the build declared (AUTO, LOCAL, CI or STRICT). effective is what AUTO resolved to on this run. |
changedFiles | int | Total diff size across every bucket. |
buckets | object | Five integer counts: ignored, outOfScope, production, test, unmapped. |
samples | object | Up 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. |
situation | string | One of the eight situations. |
action | object | name is SELECTED, FULL_SUITE or SKIPPED. source is MODE_DEFAULT or EXPLICIT, the tier that resolved it. |
outcome | object | kind 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. |
modules | array | One 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. |
discovery | object | Whether discovery ran in parallel, its thread count, the total time, and perStrategy timings with the number of tests each strategy found. |
headerEdges | object | How 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). |
springEscalation | object | effect 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. |
actionMatrix | object | Every situation mapped to its {action, source} pair. A test pins this, so a new situation cannot be added without updating the renderer. |