Patterns for writing acceptance tests using
Works with
terraform-plugin-testing
with the Plugin Framework.
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionprovider-test-patternsExecute the skills CLI command in your project's root directory to begin installation:
Fetches provider-test-patterns from hashicorp/agent-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate provider-test-patterns. Access via /provider-test-patterns in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
0
total installs
0
this week
522
GitHub stars
0
upvotes
Run in your terminal
0
installs
0
this week
522
stars
Patterns for writing acceptance tests using terraform-plugin-testing with the Plugin Framework.
Source: HashiCorp Testing Patterns
References (load when needed):
references/checks.md — statecheck, plancheck, knownvalue types, tfjsonpath, comparersreferences/sweepers.md — sweeper setup, TestMain, dependenciesreferences/ephemeral.md — ephemeral resource testing, echoprovider, multi-step patternsThe 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.
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_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")()),
}
| 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 |
| 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 |
| 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 |
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.
ConfigStateChecks: []statecheck.StateCheck{
stateCheckExampleExists(resourceName, &widget),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("name"), knownvalue.StringExact("my-widget")),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("enabled"), knownvalue.Bool(true)),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("id"), knownvalue.NotNull()),
statecheck.ExpectSensitiveValue(resourceName,
tfjsonpath.New("api_key")),
},
Do not mix Check (legacy) and ConfigStateChecks in the same step.
CheckDestroy on TestCase requires TestCheckFunc. The Check field on
TestStep also accepts TestCheckFunc but prefer ConfigStateChecks for new
tests.
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(name, "key", "expected"),
resource.TestCheckResourceAttrSet(name, "id"),
resource.TestCheckNoResourceAttr(name, "removed"),
resource.TestMatchResourceAttr(name, "url", regexp.MustCompile(`^https://`)),
resource.TestCheckResourceAttrPair(res1, "ref_id", res2, "id"),
),
ComposeAggregateTestCheckFunc reports all errors; ComposeTestCheckFunc
fails fast on the first.
Use numbered format verbs — %[1]q for quoted strings, %[1]s for raw:
func testAccExampleConfig_basic(rName string) string {
return fmt.Sprintf(`
resource "example_widget" "test" {
name = %[1]q
}
`, rName)
}
func testAccExampleConfig_full(rName, description string) string {
return fmt.Sprintf(`
resource "example_widget" "test" {
name = %[1]q
description = %[2]q
enabled = true
}
`, rName, description)
}
Steps: []resource.TestStep{
{
Config: testAccExampleConfig_basic(rName),
ConfigStateChecks: []statecheck.StateCheck{
stateCheckExampleExists(resourceName, &widget),
statecheck.ExpectKnownValue(resourceName,
tfjsonpath.New("name"), knownvalue.StringExact(rName)),
},
},
{
Config: testAccExampleConfig_full(rName, "updated"),
CoPrerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
cexll/myclaude
github/awesome-copilot
github/awesome-copilot
giuseppe-trisciuoglio/developer-kit
giuseppe-trisciuoglio/developer-kit
wshobson/agents
provider-test-patterns is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Solid pick for teams standardizing on skills: provider-test-patterns is focused, and the summary matches what you get after install.
Useful defaults in provider-test-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Registry listing for provider-test-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
Useful defaults in provider-test-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
provider-test-patterns fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
Registry listing for provider-test-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
provider-test-patterns has been reliable in day-to-day use. Documentation quality is above average for community skills.
Useful defaults in provider-test-patterns — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Registry listing for provider-test-patterns matched our evaluation — installs cleanly and behaves as described in the markdown.
showing 1-10 of 28