Search⌘ K
AI Features

Challenge: Using Mocks on Loosely Coupled Code

Explore how to write effective unit tests for an API controller with external dependencies by using mocks. Learn to mock services for payment, shipment, and cart management, and validate controller behavior based on business rules, improving your skills in handling loosely coupled code.

Introduction

In this project, you’ll write unit tests that test the behavior of a class using mocks. An assessment rubric is provided to guide you on whether or not you have applied the principles taught in this chapter.

Self assessment rubric

I have… Emergent Satisfactory Excellent
Used the principles in the previous lessons Did not apply principles taught in the previous section Partially used principles taught from the previous section Used all the principles taught in the previous section
Used mocks Mocks not used Started to use mocks Mocks used extensively; used advanced features of a mocking framework

Application code summary

...