Code-Alongs: Advanced Testing

Overview

Welcome to the Code-Alongs for Sprint 11! In these sessions, you'll work alongside your instructors to apply the concepts you've learned about advanced testing techniques, mocking, and AWS Lambda functions in practical, hands-on exercises.

Code-Along 1: Mocking External Services

In this code-along, you'll practice implementing mocks for external service dependencies in your unit tests.

What We'll Build

We'll create a weather notification service that depends on an external weather API and a notification service. You'll learn how to effectively mock these dependencies to create reliable, deterministic tests.

Key Concepts

  • Creating mock objects for external services
  • Stubbing method responses for different test scenarios
  • Verifying interactions with mocked dependencies
  • Writing tests for normal operations and edge cases

Code-Along 2: Testing With PowerMock

Learn how to use PowerMock to test code that relies on static methods and other challenging constructs.

What We'll Build

We'll work with a utility class that includes static methods for date manipulation and configuration management. You'll learn how to effectively test code that depends on these static utilities.

Key Concepts

  • Setting up PowerMock in your test environment
  • Mocking static method calls
  • Testing code that uses the current date/time
  • Refactoring for better testability

Code-Along 3: AWS Lambda Testing

Practice creating and testing AWS Lambda functions with effective logging and error handling.

What We'll Build

We'll create an API for a product catalog that uses AWS Lambda functions and DynamoDB. You'll learn how to locally test Lambda functions and implement effective logging for debugging.

Key Concepts

  • Creating Lambda functions in Java
  • Implementing proper error handling
  • Adding structured logging
  • Testing Lambda functions locally
  • Using AWS SDK mocks in tests

Preparing for Code-Alongs

To get the most out of these sessions:

  • Review the corresponding module materials beforehand
  • Clone the repositories before the session starts
  • Install the necessary dependencies
  • Come prepared with questions about the concepts

Remember that code-alongs are interactive, so don't hesitate to ask questions and participate actively during the sessions!