Chapter 37: Integration and Contract Testing

Contract Testing with Buf

# Buf detects breaking changes in your .proto files:
$ buf breaking --against .git#branch=main
proto/user/v1/service.proto:10:3: Field "2" on message "User" changed type from "string" to "int32".

Integration Testing

Testcontainers Pattern

// Start dependencies in Docker, run tests against them:
// 1. Start Redis container
// 2. Start your gRPC service container (connected to Redis)
// 3. Create gRPC client pointing to service container
// 4. Run test scenarios
// 5. Tear down containers