Scrivio Interview library
ScenarioIntermediate7 min read · updated 12 November 2026

A suite has 400 tests guarded by assumeTrue(dockerAvailable()). CI reports green builds, but a database migration bug reached production because those tests were silently skipped on the new CI runners. How do you prevent this?

An assumption that fails does not fail the test; it aborts it, and build tools count an aborted test as skipped, so the build stays green. We prevent a repeat by making Docker mandatory in CI (the guard asserts instead of assumes when a CI flag is set), by alerting on the number of skipped tests per build, and by reviewing every conditional guard on a schedule.

Why this question is asked

This failure is painful because nothing looked wrong. The pipeline was green, the report said the build passed, and yet 400 tests that protect the database migrations never ran. Interviewers ask it because it tests whether we understand what an assumption really does in JUnit 5, and whether we think about test results as data that must be watched, not just a pass or fail light. In this answer, we will recap how assumptions work, see exactly why the build stayed green, make Docker mandatory in CI while keeping the convenience for laptops, add monitoring for skipped tests, and set up a review habit so conditional tests do not rot.

1A Quick Recap of Assumptions

An assertion checks the behaviour we are testing. If assertEquals() fails, the test fails and the build goes red. An assumption is different: it checks whether the test makes sense to run at all. If assumeTrue(condition) sees false, JUnit throws a TestAbortedException, stops the test and marks it as aborted.

The intent is reasonable. A developer without Docker on a laptop should not see 400 red tests that say nothing about the code. So the test quietly steps aside. The trouble is that the same quiet step happens on a CI runner where Docker was supposed to be available and is not.

Java
@Test
void migrationAddsInvoiceColumn() {
assumeTrue(dockerAvailable()); // false on the new runners
// start PostgreSQL in a container, run Flyway, check the schema ...
}
// Surefire summary on the new runner:
// Tests run: 1250, Failures: 0, Errors: 0, Skipped: 400
// BUILD SUCCESS

Notice the last two lines. The skipped count jumped from near zero to 400, but the build still says success. Surefire and Gradle both report aborted tests under the skipped column, and most CI dashboards only colour the build by failures and errors.

2Why the Build Stayed Green

The new CI runners were probably set up without access to a Docker daemon, for example a different runner image, a rootless setup without the socket mounted, or a security policy that removed Docker in Docker. dockerAvailable() correctly returned false, and every guarded test aborted.

So each piece behaved exactly as designed. The assumption did its job, the build tool counted the tests as skipped, and the pipeline only fails on failures. The gap is that nobody had said that, on CI, missing Docker is itself a failure. An environment problem was turned into a silent skip, and the migration bug walked through the gap.

Step throughHow a missing Docker daemon became a green build
  1. Runner starts without a Docker socket
  2. dockerAvailable() returns false
  3. assumeTrue throws TestAbortedExceptionthe test is aborted, not failed
  4. Build tool counts it as skipped400 skipped, 0 failures
  5. Did anything watch the skipped count?
    YesAlert and stop the releaseNoBUILD SUCCESS, the bug ships

5 steps in order. Play them, or step through them one at a time.

Every step worked as designed. The missing piece was a rule that CI must have Docker.

3Fix 1: Make Docker Mandatory in CI

The most direct fix is to have one guard that behaves differently depending on where it runs. On a laptop it assumes, so the test steps aside. On CI it asserts, so missing Docker fails loudly in the first test, with a message that says what is wrong.

Java
final class Infra {
// CI sets -Dtests.requireDocker=true (or the CI environment variable)
private static final boolean REQUIRED =
Boolean.getBoolean("tests.requireDocker") || System.getenv("CI") != null;
static void requireDocker() {
boolean available = DockerClientFactory.instance().isDockerAvailable();
if (REQUIRED) {
assertTrue(available, "Docker is required on CI but is not available"); // fails the build
} else {
assumeTrue(available, "Docker not available, skipping locally"); // aborts on laptops
}
}
}

Notice that the decision moved from each test into one place. The 400 tests now call Infra.requireDocker(), and the rule about where Docker is optional lives in a single class. Many teams go one step further and add a first pipeline step that runs docker info and fails the job before any test starts. That fails in seconds instead of minutes and gives the clearest message of all.

4Keeping Testcontainers' Skip for Local Runs Only

Testcontainers has the same idea built in: @Testcontainers(disabledWithoutDocker = true) disables the class when Docker is missing. It is convenient on a laptop and dangerous on CI for exactly the reason above. So we should not hard-code it on every class.

A clean way is to put the annotation on a small local-only meta-annotation, or to leave disabledWithoutDocker at its default of false so that, without Docker, the container start fails with a clear error. If a team wants the local convenience, it can be switched on by a Maven profile or a Gradle property that developers use and CI never sets. The point is that skipping must be an explicit choice of the environment, not a default that follows the code everywhere.

Java
// Default: no skip. Without Docker the container fails to start -> the test errors.
@Testcontainers
class MigrationIT {
@Container
static PostgreSQLContainer<?> db = new PostgreSQLContainer<>("postgres:17");
}
// Local profile only: mvn verify -Plocal-no-docker sets -Dtests.requireDocker=false

5Fix 2: Watch the Skipped Count

Even with the guard, we want a second safety net, because some other assumption will fail for some other reason next year. The test reports already contain the data. Surefire and Failsafe write XML files with a skipped attribute per test suite, and Gradle writes the same JUnit XML format. JUnit's own console launcher and the Open Test Reporting format list aborted tests separately from disabled ones, which is even more precise.

We collect the total skipped count per build and compare it with the previous successful build on the same branch. A rule such as 'fail or alert when skipped tests grow by more than 20 or by more than 5 percent' would have caught the jump from 3 to 400 on the very first run on the new runners. Some teams also publish a fixed expected minimum, for example 'module db-migrations must execute at least 380 tests', which catches both skips and accidental exclusion.

Signals that would have caught it
SignalWhere it comes fromWould it catch this?
Build statusfailures and errors onlyNo, it was green
Skipped count vs last buildJUnit XML skipped attributeYes, 3 -> 400
Minimum executed tests per moduleCI check on the reportYes, 850 < 1230
docker info as a pipeline stepCI job definitionYes, before any test

6Reviewing Conditional Tests So They Do Not Rot

Assumptions, @EnabledIf, @DisabledOnOs, @EnabledIfEnvironmentVariable and plain @Disabled all share one weakness: once a test stops running, nobody notices when it stops compiling against reality. A periodic review, for example once a quarter, lists every conditional annotation and assumption in the codebase with a simple search, and for each one asks whether the condition still holds and whether some environment still runs the test. A test that runs nowhere is not a test; it is dead code that gives false comfort.

7Follow-up questions

Is assumeTrue() ever the right tool in CI?

Yes, when the condition is genuinely optional for that environment, for example a test that only makes sense on Windows runners while most runners are Linux. The rule is that every assumption should state which environments must run the test, and at least one CI job must be one of them. If no job runs it, the assumption is hiding a gap.

What is the difference between a disabled test and an aborted test in JUnit 5?

A disabled test is skipped before it starts, because of @Disabled or a condition annotation such as @EnabledOnOs; its body never runs. An aborted test starts, then an assumption fails inside it and JUnit stops it. Build tools usually count both as skipped, but the JUnit Platform events and the Open Test Reporting output keep them apart, which helps when we investigate.

Why not just remove all the assumptions?

Developers without Docker would then see hundreds of failures that have nothing to do with their change, and they would learn to ignore red builds, which is worse. The better design keeps the local convenience but makes it a decision of the environment, controlled by a flag that CI never sets.

8Conclusion

In this answer, we saw that a failing assumption aborts a test and that build tools report it as skipped, so a whole runner without Docker can produce a green build. We fixed the immediate cause by putting the Docker check in one guard that asserts on CI and assumes only locally, kept Testcontainers' disabledWithoutDocker behind a local profile, added monitoring of skipped and executed test counts per build, and set up a regular review of conditional tests so they do not quietly stop running.

What to say in the interviewAbout 80 seconds aloud

Open with

The root cause is that assumeTrue does not fail a test, it aborts it, and Surefire and Gradle report aborted tests as skipped. So when the new runners came up without a Docker daemon, all 400 tests aborted, the skipped count went from a handful to 400, and the build was still green because CI only looks at failures and errors.

Then, if they want more

I would fix it in three layers. First, CI must treat missing infrastructure as a failure. I would replace the scattered assumeTrue calls with one guard that asserts when a CI flag is set and only assumes on a laptop, and I would add a docker info step at the start of the pipeline so it fails in seconds.

Testcontainers' disabledWithoutDocker would only be switched on through a local profile, never by default. Second, I would treat skipped counts as a signal: collect them from the JUnit XML reports, compare each build with the previous one, and alert on a large jump, or set a minimum number of executed tests per module.

That would have caught this on the first run. Third, I would review every assumption and conditional annotation regularly and make sure each one names an environment that actually runs the test, because tests that run nowhere rot quietly.

About this answer

Last updated
12 November 2026
Versions it names
JUnit 5
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
JUnit user guide
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A suite has 400 tests guarded by assumeTrue(dockerAvailable()). CI reports green builds...": https://scrivio-interview-library.netlify.app/java/junit/ab03480785/