Skip to main content

test-order Cheat Sheet

Quick reference for the most common commands. For full details see the CLI Reference or Maven Plugin docs.


Plugin setup (Maven)

Add the plugin to your pom.xml:

<plugin>
<groupId>me.bechberger</groupId>
<artifactId>test-order-maven-plugin</artifactId>
<version>0.1.0</version>
<extensions>true</extensions> <!-- required -->
<executions>
<execution>
<goals><goal>prepare</goal></goals>
</execution>
</executions>
</plugin>

Add to ~/.m2/settings.xml once so test-order: prefix works:

<settings>
<pluginGroups>
<pluginGroup>me.bechberger</pluginGroup>
</pluginGroups>
</settings>

Plugin setup (Gradle)

// settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
}
}

// build.gradle
plugins { id 'me.bechberger.test-order' version '0.1.0' }

Daily development (Maven)

WhatCommand
Normal run (auto learn/order)mvn test
Run only affected testsmvn test-order:affected test
Then run deferred testsmvn test-order:run-remaining test
Force re-learn (after big refactor)mvn test -Dtestorder.mode=learn
Skip test-order entirelymvn test -Dtestorder.skip=true

Daily development (Gradle)

WhatCommand
Normal run (auto learn/order)./gradlew test
Run only affected tests./gradlew testOrderAffected
Then run deferred tests./gradlew testOrderRunRemaining
Force re-learn (after big refactor)./gradlew test -Dtestorder.mode=learn
Skip test-order entirely./gradlew test -Dtestorder.skip=true

Inspect and debug (Maven / Gradle equivalent)

WhatMavenGradle
Show test ranking and scoresmvn test-order:show./gradlew testOrderShow
Explain score for one testmvn test-order:explain -Dtestorder.explain.test=com.Foo./gradlew testOrderExplain -Ptest=com.Foo
Interactive HTML dashboardmvn test-order:dashboard./gradlew testOrderDashboard
Live dashboard (auto-refresh)mvn test-order:serve./gradlew testOrderServe
Health check / diagnose setupmvn test-order:diagnose./gradlew testOrderDiagnose
What changed (dry-run)mvn test-order:show -Dtestorder.debug=truesame
List all goalsmvn test-order:help./gradlew testOrderHelp

CI — fast feedback loop

Single-job with caching (minimal, any CI):

# Restore .test-order/ from cache before 'mvn test'
# Save .test-order/ to cache after (even on failure)

Two-phase (fail fast):

mvn test-order:affected test # fast: only affected tests
mvn test-order:run-remaining test # slow: everything else (only if phase 1 passes)

Three-tier CI (tiered):

# Tier 1: affected tests only
mvn test-order:tiered-select test -Dtestorder.changeMode=since-last-commit

# Tier 2: top-scored remaining
mvn test-order:run-tier test -Dtestorder.tiered.currentTier=2

# Tier 3: everything else
mvn test-order:run-tier test -Dtestorder.tiered.currentTier=3

For full YAML examples: ci-examples/


Key properties

PropertyDefaultDescription
testorder.modeautoauto / learn / order / skip
testorder.changeModeuncommittedauto / uncommitted / since-last-commit / since-last-run / explicit
testorder.changed.classesExplicit changed class FQCNs (comma-separated; use with changeMode=explicit)
testorder.instrumentation.modeMEMBERCLASS / METHOD / MEMBER — trade-off between accuracy and overhead
testorder.skipfalseSkip test-order entirely
testorder.debugfalseVerbose output showing change detection and ordering decisions
testorder.autoLearnRunThreshold10Force re-learn after N order-mode runs
testorder.affected.topN-1Max number of tests for affected goal (-1 = all affected)
testorder.flaky.retries0Retry FLAKY-classified tests on failure (recommended: 2). See FLAKY_AND_CACHING.mdx.
testorder.flaky.quarantinefalseReport FLAKY-test failures as aborted (skipped) instead of failed
testorder.cache.skipUnchangedfalseSkip tests whose deps are unchanged and that passed the last N runs
testorder.cache.minPassStreak3Required consecutive pass streak before cache eligibility
testorder.auto.alwaysLearnfalseAlways attach learn agent in auto mode (pair with selective for low-overhead incremental index updates)
testorder.learn.selectivefalseInstrument only changed classes + transitive callees — keeps learn overhead proportional to change size

Troubleshooting quick-fixes

First step — always run: mvn test-order:diagnose
It checks index health, permissions, package filters, and prints actionable fix steps.

SymptomFix
"Wrote fallback payloads" every runAdd <extensions>true</extensions> to the plugin block in pom.xml
Tests always in default orderCheck .test-order/test-dependencies.lz4 exists; re-run mvn test
No plugin found for prefix 'test-order'Add me.bechberger to <pluginGroups> in ~/.m2/settings.xml
All scores 0, no reorderingRun with -Dtestorder.debug=true — likely no changed classes detected
Empty or tiny index after learnSet -Dtestorder.includePackages=com.yourpackage (package filter too narrow)
JaCoCo reports 0% coverageChange Surefire <argLine> to @{argLine}
Failed to execute auto workflowRun mvn test-order:diagnose; check permissions on .test-order/
Tests skipped unexpectedlyCold-start without index — affected/tiered goals fall back to all tests; run mvn test first
Every test lands in tier-1 in CIShallow clone hides HEAD~1. On GitLab set variables: { GIT_DEPTH: 0 }; on GitHub Actions use actions/checkout@v4 with fetch-depth: 0; or use -Dtestorder.changeMode=since-last-run.
Learn run completes but tests still run in alphabetical ordertestorder.skip=true is set, or the JUnit/TestNG extension isn't on the test classpath — check -Dtestorder.debug=true output; ensure no -Dtestorder.skip=true in CI env vars or pom.xml; verify test-order-junit or test-order-testng is on the test classpath
"Binary read error" or index appears corruptPartial CI cache restore or interrupted learn run left a truncated .lz4 file — rm -rf .test-order/ && mvn test to force a clean learn run
Tests start failing in new/unexpected order after enabling test-orderPre-existing isolation bug (shared static state, temp files, DB rows) exposed by reordering — run mvn test -Dtestorder.shuffle=true to reproduce, then see DETECT_DEPENDENCIES.md
-Dtest=... filter active, but no auto-selection / reordering happeningIntentional: test-order skips auto-selection when -Dtest is set and delegates to Surefire (see INFO log). Use -Dtestorder.mode=order with -Dtest for ordering-only.

Nuclear reset: rm -rf .test-order && mvn test -Dtestorder.mode=learn


MIT licensed — see LICENSE