SkillByAIOpen interactive version →

JUnit 5 & Mockito

Test Java code with JUnit 5 and Mockito: assertions, lifecycle, parameterized tests, mocks, verification, test design, Spring test slices and Testcontainers.

Start course →

What you'll learn

Syllabus

Unit Testing Foundations

  1. Why Automated Tests
  2. JUnit Platform, Jupiter and Build Setup
  3. Writing Your First Tests

JUnit Jupiter in Depth

  1. Assertions, Exceptions and AssertJ
  2. Lifecycle, Nested Tests, Tags and Display Names
  3. Parameterized Tests

Advanced JUnit Features

  1. The Extension Model, @TempDir and @Timeout
  2. Assumptions and Conditional Execution
  3. Dynamic Tests, Ordering and Parallel Execution

Mockito Basics

  1. Test Doubles: Dummies, Stubs, Fakes, Spies and Mocks
  2. Creating Mocks and Stubbing
  3. Argument Matchers and Advanced Stubbing

Verification and Advanced Mockito

  1. Verifying Interactions and Capturing Arguments
  2. Spies, Static and Final Mocking
  3. BDD Style and Mocking Guidelines

Testable Design and Test Quality

  1. Designing Code That Is Easy to Test
  2. Test Smells and Flaky Tests
  3. Test-Driven Development

Testing Spring Boot Applications

  1. @SpringBootTest and Test Slices
  2. Integration Tests with Testcontainers
  3. Testing Repositories and HTTP Clients

Coverage, CI, Case Study and Revision

  1. Coverage and Mutation Testing
  2. Running Tests in CI
  3. Case Study: Testing an Order Service End to End
  4. Revision and Interview Questions