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
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.
Chapters
Spring Boot 4 Testing, 9 out
1Spring Boot Testing Tutorial for Beginners: The App, HTTP and Boot 3 vs 43:312Why Write Tests? The Test Pyramid Explained with One Real Bug3:123JUnit 6 Tutorial for Beginners: First Unit Test with AssertJ and @ParameterizedTest3:544Mockito Tutorial for Beginners: Test a Spring Boot Service Without a Database3:405Spring Boot 4 Controller Test: @WebMvcTest and MockMvc Tutorial3:256Spring Boot @DataJpaTest Tutorial: Test JPA Queries on a Real Database4:197Spring Boot Testcontainers Tutorial: Test the Whole App on Real Postgres4:4983 Spring Boot Testing Mistakes: The Test Passes but the Price Is Wrong4:149Test a Spring Boot Controller: @WebMvcTest + MockMvc0:57Keep going
More walkthroughs.
JUnit 6 Tutorial for Beginners: First Unit Test with AssertJ and @ParameterizedTest, Video.
Java Records Explained: Stop Writing Boilerplate (Complete Guide), Video.
3 Spring Boot Testing Mistakes: The Test Passes but the Price Is Wrong, Video.
Spring Boot Testcontainers Tutorial: Test the Whole App on Real Postgres, Video.
