HashiCorp/provider-test-patterns — Agent Skills | officialskills.sh
Back to skills

provider-test-patterns

officialtesting

Patterns for writing Terraform provider acceptance tests using terraform-plugin-testing with the Plugin Framework.

Setup & Installation

npx skills add https://github.com/hashicorp/agent-skills --skill provider-test-patterns
or paste the link and ask your coding assistant to install it
https://github.com/hashicorp/agent-skills/tree/main/terraform/provider-development
View on GitHub

What This Skill Does

Patterns for writing Terraform provider acceptance tests using terraform-plugin-testing with the Plugin Framework. Covers TestCase and TestStep structure, ConfigStateChecks with custom StateCheck implementations, plan checks, import testing, sweepers, and ephemeral resource testing. Includes concrete scenarios for basic, update, disappears, validation, and regression tests.

Rather than piecing together terraform-plugin-testing patterns from scattered docs and provider examples, this skill gives you the full test lifecycle, field reference, and reusable helper patterns in one place.

When to use it

  • Writing acceptance tests for a new Terraform provider resource from scratch
  • Debugging a flaky import test with ImportStateVerify failures
  • Adding a regression test that reproduces a specific GitHub issue before fixing it
  • Replacing legacy TestCheckFunc assertions with ConfigStateChecks in existing tests
  • Testing ephemeral resources that must not appear in state after apply