Skip to main content

JUnit

Migrating to Testcontainers 2.0: Artifact Renames, Package Moves and JUnit 6

Testcontainers 2.0 bundles three independent changes under one version number: 61 artifacts renamed with a testcontainers- prefix, JUnit 4 support physically removed from the GenericContainer type hierarchy (not deprecated — verified by jar inspection, zero classes implement TestRule), and the default Docker API version bumped from 1.32 to 1.44, which is what actually fixes the real Docker Engine 29 compatibility break reported in testcontainers-java#11235. Includes a self-caught mistake: @EnabledIfDockerAvailable only works on the class, not the method, because TestcontainersExtension starts @Container fields in beforeAll before any method-level condition runs.

JUnit 6

Complete guide to JUnit 6 with links to all articles covering getting started, core patterns, advanced techniques, mocking, extensions, integration testing, and best practices.

Modern Java Testing: JUnit 6 + AssertJ + Mockito 5 + Testcontainers

A practical guide to the modern Java test stack — JUnit 6 as the runner, AssertJ for fluent assertions, Mockito 5 for mocking, and Testcontainers for real infrastructure. Includes runnable examples for each and AI prompts to generate and refactor tests.

JUnit 6 Nullability: @Nullable, @NonNull and @NullMarked Explained

A practical guide to JUnit 6 nullability annotations via JSpecify: @Nullable, @NonNull, and @NullMarked. Covers what each annotation means, how they improve compile-time null safety, IDE and static analysis integration, Kotlin interop, and complete Java code examples for each annotation.

10 AI Prompts to Debug and Fix JUnit 6 Test Failures

10 AI prompts for debugging and fixing broken, flaky, and incorrectly behaving JUnit 6 tests. Each prompt is structured to provide complete failure context — stack traces, test code, production code — and diagnose root causes across assertion errors, NPEs, Mockito issues, Spring context failures, Testcontainers problems, and more.

10 AI Prompts to Optimise and Update Existing JUnit 6 Tests

10 AI prompts to optimise, update, and improve existing JUnit 6 test classes. Covers refactoring for readability, JUnit 4 migration, removing unnecessary Spring contexts, fixing brittle mocks, adding boundary tests, consolidating duplicates, restructuring with @Nested, and full quality audits.

10 AI Prompts to Generate JUnit 6 Tests for New Projects

10 ready-to-use AI prompts to generate high-quality JUnit 6 test cases for new Java projects. Each prompt is engineered for GitHub Copilot, Claude, ChatGPT, or any LLM to produce complete, annotated, production-ready tests covering unit, integration, parameterized, and exception scenarios.

JUnit 6 vs Spock vs TestNG: Best Testing Framework for Java?

A comprehensive three-way comparison of JUnit 6, Spock, and TestNG. Covers syntax, data-driven tests, mocking, Spring Boot support, parallel execution, and ecosystem. Includes the same test written in all three frameworks and a clear decision guide for which to choose.

JUnit 6 vs Mockito: Roles, Differences, and Integration

A clear explanation of the distinct roles of JUnit 6 and Mockito in Java testing. Covers what each tool does, how MockitoExtension bridges them, the division of responsibility between assertions and verification, and a complete responsibilities reference table.