inflearn logo

All H2 tests pass, but there are 6 production bugs — MySQL, Redis, and Kafka integration tests with Testcontainers

Six bugs that pass H2 and mock tests but break only on production MySQL, Redis, and Kafka—reproduced and fixed one by one with Testcontainers integration tests. Plus container singletons and reuse, CI, and flaky test diagnosis.

1 learners are taking this course

Level Intermediate

Course period Unlimited

Software Test
Software Test
Spring Boot
Spring Boot
JUnit
JUnit
Docker
Docker
Testcontainers
Testcontainers
Software Test
Software Test
Spring Boot
Spring Boot
JUnit
JUnit
Docker
Docker
Testcontainers
Testcontainers

What you will gain after the course

  • Write integration tests that reproduce in the actual engine the bugs H2 and mocks miss (syntax, ordering rules, isolation levels, TTL, message keys, and duplicate delivery).

  • Create a test environment that mirrors production using @ServiceConnection, pinned images, and Flyway validation.

  • We make asynchronous and time-dependent tests reliable with Awaitility (until/during), Clock injection, and data cleanup.

  • Verify the effects and pitfalls of singleton containers, reuse, and parallel execution with numbers, and run them in CI.

  • We quantify flaky tests by running them repeatedly and fix them based on their causes.

If all your unit tests pass but things break in production, your tests are seeing something different from production.

Six bugs that pass all H2 and mock tests but break only on production MySQL, Redis, and Kafka—reproduced and fixed one by one with Testcontainers integration tests. Covers container singletons and reuse, CI, and flaky test diagnosis.

We follow one repository and one story from start to finish. Each lesson begins with a broken behavior and shows the red-to-green progression on screen as it runs, and checkpoint tags (step-00~41) let you jump right in at any lesson.

By the end of this course

  • Write integration tests that reproduce bugs H2 misses (syntax, sorting rules, isolation levels, TTL, message keys, duplicate consumption) in the actual engine.

  • Create a test environment that matches production using @ServiceConnection, pinned images, and Flyway validation.

  • Use Awaitility (until/during), inject a Clock, and clean up data to make asynchronous and time-dependent tests reliable.

  • Quantify the benefits and pitfalls of singleton containers, reuse, and parallel execution, and run them in CI.

  • Make flaky tests measurable through repeated runs and fix them based on their causes.

Recommended for those who:

  • Spring backend developers who write unit tests but have experienced bugs that only occur in production.

  • Teams looking to move their test suites built with H2 and mocks to real databases, Redis, and Kafka.

  • People who tried Testcontainers but gave up because it was slow and sometimes flaky.

Curriculum (7 sections · 42 lessons · approximately 316 minutes)

  • Section 0. Getting Started — Green checks, but it breaks in production — Complete demo: 6 production bugs missed by 9 green checks, First bug in 5 minutes: purchase amount is 0 won, Hands-on repository and checkpoint tags, Docker 29 pitfall: client version 1.32 is too old, What H2 and mock tests prove—and what they can’t, Dissecting the first container test: lifecycle, logs, and waiting

  • Section 1. What breaks only on real MySQL — Syntax differences: LIMIT in an IN subquery, collation: the expected value in the H2 test was wrong, transaction isolation: REPEATABLE READ snapshots, pinning image tags and matching the production version, running the same tests with a PostgreSQL container, @ServiceConnection and @DynamicPropertySource

  • Section 2. Schema and Test Data — Have tests verify Flyway migrations first, reproduce migration failures in tests, three types of test data: SQL, builders, and repositories, @Sql and initialization scripts, when you need lots of fixture data, use the same containers for local runs too

  • Section 3. Things That Only Break with Redis and Kafka — Redis: SET clears the TTL, verify without waiting for expiration, start a Kafka container (KRaft), message keys and partitions: ordering breaks, duplicate messages: points were added twice, verify errors, retries, and DLTs.

  • Section 4. Time, Asynchrony, and Test Isolation — Awaitility: Wait Without Sleep, during: Verify That Nothing Else Happens, Time-Dependent Code: Injecting a Clock, Test Isolation: Data Cleanup Strategies, Finding Test Order Dependencies, Parallel Execution and Container Conflicts

  • Section 5. Speed and CI — Why is it slow? Measure time in segments, Spring context caching and container lifecycle, singleton container pattern, container reuse: local only, running Testcontainers on GitHub Actions, reducing CI time: caching and images

  • Section 6. Diagnosing flaky tests and capstone — Flaky test diagnosis ①: Measure the reproduction rate through repeated runs, Flaky test diagnosis ②: Fix the causes, Overall review: Bugs caught and execution time, Capstone ①: An unfamiliar bug — symptoms and clues, Capstone ②: Solution and comparison, Wrap-up: Checklist and next steps

Practice Environment

The practice ZIP contains the order service repository for the fictional company “Loop Market” (42 Git tags, one for each lesson), 42 reproduction scenarios, one per lesson, and a checklist. The figures shown were measured on the creator’s laptop and may vary depending on the environment.

Prerequisites

  • Experience writing unit tests and using mocks.

  • Experience building APIs with Spring Boot

  • A PC running JDK 21 and Docker.

What This Course Does Not Cover

  • Introduction to JUnit and Mockito Syntax

  • Cache and message queue design (Outbox, etc.)

  • Load and Performance Testing

  • Kubernetes and Container Operations

Notice

The audio for this lecture was generated using text-to-speech (TTS). All data is simulated for educational purposes, and figures may vary depending on the execution environment.

Recommended for
these people

Who is this course right for?

  • A Spring backend developer who writes unit tests but has run into bugs that only occur in production.

  • Teams that want to migrate test suites built with H2 and mocks to real databases, Redis, and Kafka

  • For those who tried using Testcontainers but gave up because it was slow and occasionally broke.

Need to know before starting?

  • Have experience using unit tests and mocks.

  • Experience building an API with Spring Boot.

  • JDK 21 · A PC that can run Docker

Hello
This is dorian05202988

Career Verified

A data craftsman with over 20 years of experience in databases and IT. As a DBA and manager of a DB Platform team, I work with database platforms and specialize in MySQL, PostgreSQL, Oracle, MongoDB, SQL tuning, AWS, Terraform, and Python. Drawing on experience in the gaming, finance, and IT services industries, I explain database and cloud architecture. I have published 『Oracle Practical Tuning: Learning SQL Patterns』 and 『Oracle Pro*C Practical Project Guide』, and have presented on serverless architectures, database selection, and multi-database strategies at AWS Summit 2018 and 2019 and DataYa Nolja 2020. Recently, I have been working on slow-query analysis and tuning recommendations using Bedrock LLM, automated DB specification sizing, and query workflows through a DB metadata MCP server and Slack bot. I explain database automation for developers and AI applications for non-developers through hands-on exercises tailored to the audience and objectives of each course. Rather than applying AI suggestions as-is, I teach a decision-making framework that verifies result equivalence, execution plans, and observability conditions, and defers action when the supporting evidence is insufficient. Company operational data and credentials are not included in the course materials.

More

Curriculum

All

42 lectures ∙ (5hr 15min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

Not enough reviews.
Please write a valuable review that helps everyone!

dorian05202988's other courses

Check out other courses by the instructor!

Similar courses

Explore other courses in the same field!

Limited time deal

$56,320.00

20%

$55.00