Terraform
Overview
This guide helps you migrate a Terraform provider's acceptance testing dependencies from SDKv2 to the plugin testing module. We recommend migrating to terraform-plugin-testing to take advantage of new features of the testing module and to avoid importing the SDKv2 for providers that are built on the plugin Framework.
This guide provides information and examples for most common use cases, but it does not discuss every nuance of migration. You can ask additional migration questions in the HashiCorp Discuss forum. To request additions or updates to this guide, submit issues or pull requests to the terraform-plugin-testing
repository.
Migration steps
Take the following steps when you migrate a provider's acceptance tests from SDKv2 to the testing module:
- Change all instances of the following Go import statements in
*_test.go
files:github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest
togithub.com/hashicorp/terraform-plugin-testing/helper/acctest
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource
togithub.com/hashicorp/terraform-plugin-testing/helper/resource
github.com/hashicorp/terraform-plugin-sdk/v2/terraform
togithub.com/hashicorp/terraform-plugin-testing/terraform
- Get and download the latest version of terraform-plugin-testing:
$ go get github.com/hashicorp/terraform-plugin-testing@latest
- Clean up
go.mod
:
$ go mod tidy
- Verify that the tests are working as expected.