Terratest Guide
Getting Started
Installation
go version # Should be 1.21 or highermkdir test
cd test
go mod init terraform-testsgo get -u github.com/gruntwork-io/terratest@latestBasic Test Structure
Directory Layout
infrastructure/
βββ modules/
β βββ vpc/
β βββ main.tf
β βββ variables.tf
β βββ outputs.tf
βββ test/
βββ go.mod
βββ go.sum
βββ vpc_test.goSimple Test Example
Advanced Testing Patterns
1. Retry Logic
2. HTTP Testing
3. SSH Testing
Testing Cloud-Specific Resources
AWS Resources
Azure Resources
Test Fixtures
1. Example Test Fixture
2. Using Test Fixtures
Test Parallelization
1. Parallel Test Execution
2. Resource Naming for Parallel Tests
Testing Best Practices
1. Environment Cleanup
2. Test Timeouts
3. Test Logging
CI/CD Integration
Troubleshooting
Common Issues and Solutions
Last updated