terraform-test

Write and execute Terraform tests using HCL syntax with run blocks and assertions.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/benonions/dotfiles --skill terraform-test-benonions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-test
Source: https://github.com/benonions/dotfiles/tree/main/codex/.codex/skills/community/hashicorp-agent-skills/terraform/code-generation/skills/terraform-test
Command: npx skills add https://github.com/benonions/dotfiles --skill terraform-test-benonions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide for writing and executing tests for Terraform configurations, ensuring infrastructure code quality and preventing breaking changes.

Core Features & Use Cases

  • Test Creation: Learn to write test files (.tftest.hcl) with run blocks for scenarios.
  • Validation: Use assert blocks to check resource configurations, outputs, and provider behavior.
  • Mocking: Simulate provider responses with mock_provider for isolated unit testing.
  • Use Case: When developing a new Terraform module, use this Skill to write unit tests that validate default configurations and integration tests that confirm resource creation and state, before merging changes.

Quick Start

Use the terraform-test skill to write a new test file for your Terraform module.

Frequently Asked Questions about terraform-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write tests for my Terraform configuration?

Write tests for Terraform configurations by creating `.tftest.hcl` files containing `run` blocks for specific scenarios and `assert` blocks to validate resource attributes, outputs, and provider behavior.

What is mock_provider in Terraform testing and when should I use it?

`mock_provider` in Terraform testing simulates provider responses to enable isolated unit testing without provisioning real infrastructure, allowing you to validate module logic and outputs safely and quickly.

Can I test Terraform module outputs and resource counts without applying changes?

Yes, you can test Terraform module outputs, resource counts, conditional resources, and validation rules using the plan mode to inspect configurations and assert expected behavior without applying real changes.

Does Terraform testing support both unit tests and integration tests?

Terraform testing supports both isolated unit tests using `mock_provider` and integration tests in apply mode to confirm actual resource creation and state, including cleanup procedures and troubleshooting guidance.

What are the best practices for troubleshooting failing Terraform tests?

Troubleshoot failing Terraform tests by reviewing `assert` block failures, verifying `mock_provider` configurations, checking plan versus apply modes, and following testing best practices for module validation and cleanup.