Course
Testing in Java with JUnit and Testcontainers
Test against a real database instead of a mock: JUnit 5, helpful and harmful test doubles, Testcontainers, Spring integration tests, and execution speed.
Intermediate 7 lessons
Lessons
- 1 Introduction You'll learn to recognize tests that give false confidence and to draw the useful line between unit tests and integration tests.
- 2 JUnit 5 essentials Learn to structure a readable test class using JUnit 5's lifecycle, assertions, parameterized tests, and nested tests.
- 3 Mockito Test Doubles You'll be able to tell which dependencies should be mocked and which should never be mocked, and spot tests that only verify their own setup.
- 4 Testcontainers You'll learn how to start a real PostgreSQL in a container for your tests and keep startup cost under control with reusable containers.
- 5 Spring Integration Tests Learn how to choose the right Spring context slice for each test and avoid the context reloads that blow up your suite's run time.
- 6 Test data You'll learn to build readable test objects with the builder pattern and ensure isolation between tests without relying on a frozen dataset.
- 7 Speed and reliability You'll learn to measure where your test time goes, enable parallel execution, and diagnose a flaky test instead of rerunning it.