JUnit / SBT test suite reported one or more test failures
April 30, 2026 · View on GitHub
Playbook ID: junit-test-failure
Category: test
Severity: high
Tags: java, jvm, scala, junit, sbt, gradle, test, assertion
What this failure means
One or more JVM test cases failed. The JUnit runner or SBT reported the failure
with a java.lang.AssertionError, sbt.TestsFailedException, or a
Gradle/SBT test task summary showing failed tests.
Common log signals
java.lang.AssertionError
org.junit.Assert
org.junit.ComparisonFailure
AssertionFailedError
sbt.TestsFailedException
Tests unsuccessful
test tasks failed:
testOnly failed:
Diagnosis
A JUnit, SBT, or Gradle test run terminated with a non-zero exit code. Common output formats seen in CI:
Gradle / JUnit 4/5:
com.example.MyTest > shouldDoSomething FAILED
java.lang.AssertionError: expected:<1> but was:<2>
at org.junit.Assert.fail(Assert.java:88)
SBT:
[error] 1 of 17 test tasks failed:
[error] - it:testOnly failed: sbt.TestsFailedException: Tests unsuccessful
Common causes:
- Assertion failure — a test assertion (
assertEquals,assertTrue,assertThat) did not hold; actual output diverged from expected. - Memory/resource assertion — a test that tracks heap growth or object
counts fails because GC did not reclaim expected memory in time (common
in reactive/observable library tests like RxJava's
publishNoLeak). - NullPointerException — a
nullreached a code path that did not expect it, typically caused by missing test setup or a changed API. - Binary compatibility failure — a MiMa (
mimaReportBinaryIssues) task detected that a public API signature changed in a binary-incompatible way. - Data-dependent failure — the test relies on external state (database, filesystem, network) that is absent or inconsistent in CI.
Fix steps
-
Find the failing test in the output — look for
FAILEDlines or the stack trace that followsAssertionError. -
Reproduce locally:
# Gradle ./gradlew test --tests "com.example.MyTest.shouldDoSomething" # SBT sbt "testOnly com.example.MySpec" # Maven mvn -pl module test -Dtest=MyTest#testMethod -
For
AssertionError: X -> Ymemory tests (e.g. RxJavapublishNoLeak):- Run the test in isolation with
-XX:+ExplicitGCInvokesConcurrentor add an explicitSystem.gc()call. - Check whether the test is inherently flaky (non-deterministic GC) and whether the project has a known skip annotation for such tests.
- Run the test in isolation with
-
For
sbt.TestsFailedException:- Run
sbt testOnly *FailingSpecand examine the output. - Look for
[error]lines above the exception for the actual test name and assertion message.
- Run
-
For MiMa binary compatibility (
mimaReportBinaryIssues):- Run
sbt mimaReportBinaryIssueslocally. - Add a
ProblemFilters.exclude[...]entry inbuild.sbtif the API change is intentional and the next release is major/minor.
- Run
-
Fix the root cause: update the implementation to match the test, or — if the test expectation is wrong — update the test and document the change.
Validation
./gradlew test(orsbt test/mvn test) exits zero with no failures.- The specific failing test name no longer appears in
FAILEDoutput.
Likely files to inspect
build.sbtbuild.gradlebuild.gradle.ktspom.xmlsrc/test/**/*.javasrc/test/**/*.scala
Run Faultline
faultline analyze build.log
faultline explain junit-test-failure
faultline workflow build.log --json --mode agent
Search phrases this page answers
- JUnit / SBT test suite reported one or more test failures
- Test: junit / sbt test suite reported one or more test failures
- java.lang.IllegalArgumentException
- faultline explain junit-test-failure
- Java junit / sbt test suite reported one or more test failures
Generated from playbooks/bundled/log/test/junit-test-failure.yaml. Do not edit directly — run make docs-generate.