Discover the pivotal role of test doubles in modern software testing. This introductory course will guide you through the essentials of dummies, stubs, spies, mocks, and fakes. Learn how these powerful tools help you isolate units under test, control behavior, and build reliable, fast, and maintainable tests. Step into the world of test doubles and elevate your software development skills.
Overview
Syllabus
- Unit 1: Isolating Dependencies with Test Doubles: Dummies
- Understanding EmailService in TDD with Dummy Implementations
- Enhancing Logger Interface with Severity Parameter
- Identifying and Fixing Bugs in EmailService Tests
- Implementing Dummy Dependencies in EmailService Tests
- Implementing Test Doubles for NewsletterService
- Unit 2: Isolating Dependencies with Test Doubles: Stubs
- Stubbing for Weather Alerts
- Handle Freezing Conditions with Stubs
- Refactor to Use Mockito for Stubbing
- Beware: Stormy Conditions!
- Stubbing Out Sunny Weather
- Refactor with Enums
- Unit 3: Utilizing Spies in Test Driven Development with Mockito
- Spying on Method Calls
- Spying on Urgent Notifications
- Spying on Medium Priority Notifications
- Spying on Multiple Method Calls
- Unit 4: Mocking Dependencies with Mockito
- Mock Pricing Service for Testing
- Verifying Dependencies Aren't Called using Mocks
- Expect Exceptions for Negative Prices
- Mocking Multiple Calls with Mock Implementations
- Calculating Bulk Prices
- Unit 5: Isolating Dependencies with Test Doubles: Fakes
- Using a Fake User Repository
- Expect an Exception When Adding Duplicate Users
- Update a Registered User
- Handle when Updating Non-Existent Users
- Deactivating Users
- Expect Exception when Deactivating Non-Existent Users