Master test doubles in Rust to isolate units and control behavior. This course covers the essentials of dummies, stubs, spies, mocks, and fakes using the mockall crate. Learn to verify interactions and build reliable, fast, and maintainable tests. Elevate your TDD practice by effectively decoupling your code from external dependencies.
Overview
Syllabus
- Unit 1: Isolating Dependencies with Test Doubles: Dummies
- Understanding TDD Dummy Implementations
- Enhancing Logger Interface with Severity Parameter
- Implementing Dummy Dependencies in EmailService Tests
- Implementing a Dummy-Based Test Suite
- Unit 2: Utilizing Stubs for Test-Driven Development
- Simulating Weather Alerts
- Implement Weather Alert Service
- Refactoring to a Custom Test Double
- Weather Alert Service Storm Test Task
- Implementing a Weather Alert System Using Stubs in Rust
- Refactor Weather Conditions to Use Enum for Stricter Typing
- Unit 3: Introduction to Mocks in Rust
- Mocking Dependencies in Unit Tests for Pricing Service Conversion
- Writing a Test to Prevent Unnecessary External Service Calls
- Verify Negative Price Handling in PricingService
- Implementing Custom Mocks for Currency Conversion in Rust
- Implementing and Testing Bulk Price Calculation in Pricing Service
- Unit 4: Using Fakes for Test-Driven Development in Rust
- Implementing User Registration with In-Memory Repository and Test-Driven Development in Rust
- Ensure No Duplicate Email in UserService Registration
- Updating User Name in UserService Using Test-Driven Development
- Implement User Name Update with Error Handling
- Implement User Deactivation Functionality in Rust
- Test-Driven Development: Deactivate Non-Existent User