Welcome to a crucial episode in our Test Pyramid series! As your Engineering Coach, I'll show you how to build a resilient REST API that can gracefully handle the unexpected. In this video, we'll refactor our existing book endpoint to introduce different layers of the application—Controller, Business Logic, and Repository.
The core of this episode is handling failures. We'll use a combination of Unit and Integration Tests to ensure our application can handle an unavailable database, throwing and catching the correct exceptions along the way. You'll see how to use a mocking framework like Mockery to simulate the failing database and test your code's defensive capabilities.
This video is an essential guide for anyone who wants to learn how to write robust, fault-tolerant code.
The code for this episode can be found on GitHub: https://github.com/the-engineering-co...
Previous in the Series:
If you missed the previous videos, check out our guide on testing GET endpoints and error handling:
👉 Watch The Test Pyramid: Part 3 here!
• The Test Pyramid: Part 3 - Handling Errors...
Let's Connect
For more software engineering tutorials and coaching, subscribe to The Engineering Coach on YouTube. You can also connect with me on Bluesky or Mastodon.
Mastodon: https://mastodon.social/@braddle
Bluesky: https://bsky.app/profile/braddle1.bsk...
#TestPyramid #RESTAPI #TDD #ErrorHandling #PHP #Refactoring #TheEngineeringCoach