Spring Boot 4 Testing / Part 2YOUTUBE PLAYER LOADS ON PLAYOne Bug, One Test & Test Pyramid
Springboot Testing #2

Why Write Tests? The Test Pyramid Explained with One Real Bug

Spring Boot 4 Testing3 Nov 20263:12Open on YouTube

In this lesson

Meera books 4 seats at ₹200 each. With 10% off for 4+ seats she should pay ₹720, but the app charged ₹800, and nobody noticed for a week. One small test would have caught it in seconds.

Episode 1 of Spring Boot Testing: the complete guide. We test one cinema booking app from start to finish, one layer per episode.

  • What a test is: code that runs your code and checks the answer (green = right, red = wrong)
  • Guess first: will the test pass or fail? Then how to read the red message: expected 720.00, but was 800.00
  • The app: controller (front desk), service (manager), repository (record book), database (cupboard)
  • The test pyramid: many unit tests, some slice tests, a few full tests
  • Setup in Spring Boot 4: spring-boot-starter-test (JUnit, AssertJ, Mockito) and the slice test starters webmvc-test and data-jpa-test

Next: Ep 2, your first real unit test with JUnit and AssertJ, and testing many seat counts with one test.

Built and run on Spring Boot 4.1, Java 21, JUnit 6.

Keep going

More walkthroughs.