Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution.
Install with Tessl CLI
npx tessl i github:hashicorp/agent-skills --skill terraform-test84
Quality
88%
Does it follow best practices?
Impact
84%
1.78xAverage score across 10 eval scenarios
Mock provider and assert block syntax
mock_provider block
100%
100%
mock_resource sub-block
0%
100%
mock_data sub-block
0%
100%
Assert condition field
100%
100%
Assert error_message field
100%
100%
Expect failures and variable overrides
expect_failures attribute
100%
100%
Checkable object reference
100%
100%
File-level variables block
0%
0%
Run-level variable override
0%
0%
Plan mode for validation
100%
100%
Module block testing and run output references
Module block with source
100%
100%
Run output reference syntax
100%
100%
Sequential dependency order
100%
100%
Multiple run blocks
100%
100%
tftest.hcl extension
100%
100%
Test file organization and plan vs apply modes
Tests directory
0%
66%
Unit test naming
0%
100%
Integration test naming
0%
100%
Plan mode explicit
0%
100%
Apply mode default
0%
100%
State key management and parallel execution
state_key attribute used
0%
100%
parallel attribute set
0%
0%
Separate state for parallel
0%
50%
Synchronization point
33%
100%
No cross-parallel references
66%
100%
Table of Contents
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.