JUnit 5 & Mockito
- JUnit 5 architecture: Platform, Jupiter, Vintage
- @Test, @BeforeEach, @AfterEach, @BeforeAll, @AfterAll — lifecycle methods
- @ParameterizedTest: @ValueSource, @CsvSource, @MethodSource, @EnumSource
- @RepeatedTest and @DynamicTest: factory-based test generation
- Nested tests: @Nested for organizing test classes
- JUnit 5 extensions: @ExtendWith, custom extensions, MockitoExtension
- AssertJ: fluent assertions — assertThat(), soft assertions, custom assertions
- Mockito: @Mock, @InjectMocks, when/thenReturn, verify, ArgumentCaptor
- Mockito strict stubbing: detecting unnecessary stubs
- Testing exceptions: assertThrows, assertThrowsExactly
Spring Boot Test Slices & Testcontainers
- @SpringBootTest: full context, web environment, TestRestTemplate vs MockMvc
- @WebMvcTest: controller slice — testing HTTP layer in isolation
- @DataJpaTest: repository slice with in-memory H2 database
- @MockBean vs @SpyBean: replacing beans in the context
- Testcontainers: real PostgreSQL, Kafka, Redis in tests — no mocking
- Testcontainers with JUnit 5: @Container, @Testcontainers
- Reusing containers: static container lifecycle for faster test suites
- WireMock: stubbing external HTTP dependencies
- Integration test structure: @SpringBootTest + Testcontainers as the recommended stack
- Test coverage: JaCoCo configuration, excluding generated code, meaningful thresholds
Java developers who write tests that catch real bugs, run fast enough to use constantly, and don't break every time the implementation changes.
- Write parameterized and lifecycle-managed JUnit 5 tests with AssertJ assertions
- Use Spring Boot test slices to test each layer in appropriate isolation
- Replace database and message broker mocks with Testcontainers for real infrastructure
- Apply WireMock for stable, controllable HTTP dependency stubbing
Book the JUnit 5 & Integration Testing training
A practical one-day course — works well as a follow-on to the TDD/BDD training or as a standalone testing improvement session.
Need hands-on help in your own project instead of a training? I also take on architecture and implementation work, fully remote.
Get in touch