terraform-testing

Run Terraform unit tests with mock providers and .tftest.hcl files.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/rpothin/terraform-powerplatform-res-tenantsettings --skill terraform-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: terraform-testing
Source: https://github.com/rpothin/terraform-powerplatform-res-tenantsettings/tree/main/.agents/skills/terraform-testing
Command: npx skills add https://github.com/rpothin/terraform-powerplatform-res-tenantsettings --skill terraform-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Terraform testing patterns for Power Platform modules help teams validate module behavior locally, accelerate feedback cycles, and prevent regressions without relying on live environments.

Core Features & Use Cases

  • Unit testing with mock_provider blocks to verify input validation and conditional logic without network calls.
  • Integration testing with real providers in isolated environments, enabling end-to-end validation of module behavior.
  • CI-ready test organization, clear assertions, and structure that scales with module complexity.

Quick Start

Create a tests/unit/default.tftest.hcl with a mock_provider and a simple run block, then run terraform test to execute unit tests.

Frequently Asked Questions about terraform-testing

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

FAQPage Schema
How do I run Terraform unit tests for Power Platform without external API calls?

Run Terraform unit tests for Power Platform without external API calls by defining mock_provider blocks in .tftest.hcl files and executing terraform test. Mock providers enable deterministic, isolated testing by verifying input validation and conditional logic locally without hitting live environments.

What Terraform version is required to use mock providers for testing?

Terraform 1.6+ is required to use the native terraform test command, and mock_provider blocks specifically require Terraform 1.7 or later. You need this version baseline to write deterministic unit tests with run blocks, mock_provider blocks, and assertion blocks for Power Platform modules.

What is the best way to structure Terraform tests for CI pipelines?

Structure Terraform tests for CI pipelines by organizing .tftest.hcl files into unit and integration directories, using clear assertion blocks for module behavior validation. Keep unit tests using mock providers separate from integration tests using real providers in isolated environments to scale with module complexity.

How do I validate Terraform module variables and conditional logic locally?

Validate Terraform module variables and conditional logic locally by writing run blocks with assertion blocks inside .tftest.hcl files. Using mock_provider blocks allows you to test input validation and conditional behavior deterministically without needing network connectivity or live Power Platform APIs.

Can I run integration tests with real providers alongside mock provider unit tests?

Yes, you can run integration tests with real providers in isolated environments alongside mock provider unit tests. The testing pattern supports both end-to-end validation of module behavior using real providers and fast, isolated unit tests using mock_provider blocks within the same module structure.

Why does my terraform test command fail when using mock_provider blocks?

Your terraform test command fails when using mock_provider blocks if you are running a Terraform version below 1.7. Mock providers were introduced in Terraform 1.7, so ensure your environment is updated to at least version 1.7 to properly execute deterministic unit tests with mock_provider blocks.