#terraform#testing#tftest#iac#devops

Terraform Test

Independent PiSkill directory guide. The original skill remains hosted by HashiCorp Agent Skills.

What is Terraform Test?

Guides Terraform's built-in testing framework with .tftest.hcl files, run blocks, assertions, mock providers, CI workflows, and safe validation of infrastructure behavior.

What does Terraform Test do?

Terraform Test is a HashiCorp Agent Skill for using Terraform's built-in testing framework with `.tftest.hcl` files. It covers run blocks, assertions, plan-versus-apply behavior, mock providers and CI patterns so infrastructure logic can be validated without relying only on manual plan review.

Who is Terraform Test best for?

  • Terraform module authors
  • Infrastructure teams adding regression tests
  • Developers validating modules in CI
  • Projects using mock providers for safer unit-style testing

Common use cases

  • Write assertions for a Terraform module
  • Test planned values without applying infrastructure
  • Use mock providers for controlled test scenarios
  • Add Terraform tests to a CI pipeline

How does Terraform Test work?

The skill defines test files containing one or more run blocks, chooses plan or apply behavior for each scenario, passes test variables and providers, and uses assertions to verify expected configuration. Where supported, mock providers can simulate provider behavior so logic is tested without creating real infrastructure.

Key benefits

  • Adds repeatable regression testing to Terraform
  • Supports both plan-level and apply-style scenarios
  • Can reduce unnecessary cloud resource creation with mocks
  • Integrates infrastructure testing into CI workflows

Things to know

  • Apply-mode tests can create real resources and incur cost
  • Mock providers cannot reproduce every cloud behavior
  • Terraform and provider versions affect which test features are available

Compatible tools

Claude CodeOpenAI CodexCursorGitHub Copilot

Frequently asked questions

What is a .tftest.hcl file?
It is a Terraform test file containing run blocks, variables, provider configuration and assertions used by Terraform's built-in testing framework.
Can Terraform tests run without creating real resources?
Yes. Plan-mode tests and supported mock-provider workflows can validate many behaviors without applying real infrastructure.
← Back to Skills Directory