provider-test-patterns
Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework.
Skill by hashicorpOfficial
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/hashicorp-provider-test-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, devops, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/provider-test-patterns
What's inside
- Skill name
provider-test-patterns- Description
- Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework. Covers test structure, TestCase/TestStep fields, ConfigStateChecks with custom statecheck.StateCheck implementations, plan checks, CompareValue for cross-step assertions, config helpers, import testing with ImportStateKind, sweepers, and scenario patterns (basic, update, disappears, validation, regression), and ephemeral resource testing with the echoprovider package. Use when writing, reviewing, or debugging provider acceptance tests, including questions about statecheck, plancheck, TestCheckFunc, CheckDestroy, ExpectError, import state verification, ephemeral resources, or how to structure test files.
- License
- MPL-2.0
- Metadata
- version: 0.0.1 · copyright: Copyright IBM Corp. 2026 · lifecycle-status: active
- Instructions
- 398 lines in SKILL.md · view on GitHub
Files (4)
- SKILL.md
- checks.md · references/
- ephemeral.md · references/
- sweepers.md · references/
SKILL.md (first lines)
# Provider Acceptance Test Patterns
Patterns for writing acceptance tests using
[terraform-plugin-testing](https://github.com/hashicorp/terraform-plugin-testing)
with the [Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework).
Source: [HashiCorp Testing Patterns](https://developer.hashicorp.com/terraform/plugin/testing/testing-patterns)
**References** (load when needed):
- `references/checks.md` — statecheck, plancheck, knownvalue types, tfjsonpath, comparers
- `references/sweepers.md` — sweeper setup, TestMain, dependencies
- `references/ephemeral.md` — ephemeral resource testing, echoprovider, multi-step patterns
---
## Test Lifecycle
The framework runs each TestStep through: **plan → apply → refresh → final
plan**. If the final plan shows a diff, the test fails (unless
`ExpectNonEmptyPlan` is set). After all steps, destroy runs followed by
`CheckDestroy`. This means every test automatically verifies that
configurations apply cleanly and produce no drift — no assertions needed for
that.
---
## Test Function Structure
```go
func TestAccExample_basic(t *testing.T) {
var widget example.Widget
rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
resourceName := "example_widget.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
CheckDestroy: testAccCheckExampleDestroy,
Steps: []resource.TestStep{
{
Config: testAccExampleConfig_basic(rName),
ConfigStateChecks: []statecheck.StateCheck{
stateCheckExampleExists(resourceName, &widget),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("name"), knownvalue.StringExact(rName)),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("id"), knownvalue.NotNull()),
},
},
},
})
}
```
Use `resource.ParallelTest` by default. Use `resource.Test` only when tests
share state or cannot run concurrently.
---
## Provider Factory
```go
// provider_test.go — Plugin Framework with Protocol 6 (use Protocol5 variant if needed)
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"example": providerserver.NewProtocol6WithError(New("test")()),
}
```
---
## TestCase Fields
| Field | Purpose |
|-------|---------|
| `PreCheck` | `func()` — verify prerequisites (env vars, API access) |
| `ProtoV6ProviderFactories` | Plugin Framework provider factories |
| `CheckDestroy` | `TestCheckFunc` — verify resources destroyed after all steps |
| `Steps` | `[]TestStep` — sequential test operations |
| `TerraformVersionChecks` | `[]tfversion.TerraformVersionCheck` — gate by CLI version |
---
## TestStep Fields
### Config Mode
| Field | Purpose |
|-------|---------|
| `Config` | Inline HCL string to apply |
| `ConfigStateChecks` | `[]statecheck.StateCheck` — modern assertions (preferred) |
| `ConfigPlanChecks` | `resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{...}}` |
| `ExpectError` | `*regexp.Regexp` — expect failure matching pattern |
| `ExpectNonEmptyPlan` | `bool` — expect non-empty plan after apply |
| `PlanOnly` | `bool` — plan without applying |
| `Destroy` | `bool` — run destroy step |
| `PreConfig` | `func()` — setup before step |
### Import Mode
| Field | Purpose |
|-------|---------|
| `ImportState` | `true` to enable import mode |
| `ImportStateVerify` | Verify imported state matches prior state |
| `ImportStateVerifyIgnore` | `[]string` — attributes to skip during verify |
| `ImportStateKind` | `resource.ImportBlockWithID` — import block generation |
| `ResourceName` | Resource address to import |
| `ImportStateId` | Override the ID used for import |
---
## Check Functions
### Modern: ConfigStateChecks (preferred)
Type-safe with aggregated error reporting. Compose built-in checks with custom
`statecheck.StateCheck` implementations. See `references/checks.md` for full
knownvalue types, tfjsonpath navigation, and comparers.
```goFrom hashicorp/agent-skills, MPL-2.0.
More from hashicorp/agent-skills
- 0.820score
terraform-policy
hashicorpOfficial
Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).
SkillAFreshness: A★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-test
hashicorpOfficial
Comprehensive guide for writing and running Terraform tests.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-framework-migration
hashicorpOfficial
Migrate Terraform provider resources and data sources from Plugin SDKv2 to the Plugin Framework: muxing both plugins in one provider (terraform-plugin-mux…
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
push-to-registry
hashicorpOfficial
Push Packer build metadata to HCP Packer registry for tracking and managing image lifecycle.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
aws-ami-builder
hashicorpOfficial
Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
windows-builder
hashicorpOfficial
Build Windows images with Packer using WinRM communicator and PowerShell provisioners.
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
new-terraform-provider
hashicorpOfficial
Use this when scaffolding a new Terraform provider with the Plugin Framework: workspace layout, go module setup, provider server main.go, and a provider.go…
SkillBFreshness: B★ 907Claude Code +9 - 0.772score
provider-ephemeral-resources
hashicorpOfficial
Implement Terraform provider ephemeral resources with the Plugin Framework: the Open/Renew/Close lifecycle, ephemeral schema design, registration via…
SkillBFreshness: B★ 907Claude Code +9
Signals
- Stars
- 907
- Forks
- 134
- Open issues
- 12
- Last commit (this folder)
- Aug 10, 2026 (2 months ago)
- Last release
- Aug 4, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 0.0.1
- License
- MPL-2.0
- Repository
- github.com/hashicorp/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from hashicorp
- 0.821score
Terraform
hashicorpOfficial
Generate more accurate Terraform and automate workflows for HCP Terraform and Terraform Enterprise
ConnectorAFreshness: ALocal★ 1.6KClaude Code +5 - 0.820score
terraform-policy
hashicorpOfficial
Write, test, or convert Terraform Policy files (.policy.hcl, .policytest.hcl, Sentinel→tfpolicy).
SkillAFreshness: A★ 907Claude Code +9 - 0.777score
terraform-stacks
hashicorpOfficial
Comprehensive guide for working with HashiCorp Terraform Stacks.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-docs
hashicorpOfficial
Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema…
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
terraform-search-import
hashicorpOfficial
Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management.
SkillBFreshness: B★ 907Claude Code +9 - 0.777score
provider-configuration
hashicorpOfficial
Implement Terraform provider configuration and authentication with the Plugin Framework: provider schema for credentials (Optional + Sensitive attributes)…
SkillBFreshness: B★ 907Claude Code +9
Cite this page
provider-test-patterns skill. Agent Mart. https://agentmart.dev/skills/hashicorp-provider-test-patterns (last updated 2026-10-24)