Stop rerunning your tests

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

Gradle's build cache and incremental build features can skip test runs when inputs haven't changed, saving significant time. Using `outputs.upToDateWhen { false }` to force test reruns is an anti-pattern that wastes team productivity. For genuinely non-deterministic tests (randomized, system integration, or flaky), the right approach is to model the non-determinism as explicit task inputs—such as a random seed or a date—rather than disabling caching entirely. Separate Test tasks should be created for different test types, each configured with appropriate inputs to control when reruns are necessary.

5m read timeFrom blog.gradle.org
Post cover image
Table of contents
Table of ContentsIntroductionCommunicating intent #Deterministic tests don’t need reruns #Non-deterministic tests #Model your tests properly #Discuss

Sort: