» Acceptance Tests

The framework for Terraform provider development currently relies on the acceptance test framework shipped with SDKv2. You will write and run tests with the same steps, and they are otherwise indistinguishable from testing against SDKv2. The major difference is in how the provider is specified in the TestCase struct.

» Specify Providers

In SDKv2, providers were specified by using the Providers property of the resource.TestCase to supply a map of schema.Providers.

For the framework, the same pattern applies, but instead use the ProtoV6ProviderFactories property of resource.TestCase to supply a map of functions that return a tfprotov6.ProviderServer. To get a tfprotov6.ProviderServer from a tfsdk.Provider, you need to use the tfsdk.NewProtocol6Server helper. For example:

resource.Test(t, resource.TestCase{
    PreCheck: func() { testAccPreCheck(t) },
    ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error) {
        "example_provider": func() (tfprotov6.ProviderServer, error) {
            // newProvider is your function that returns a
            // tfsdk.Provider implementation
            return tfsdk.NewProtocol6Server(newProvider()), nil
    CheckDestroy: testAccCheckExampleResourceDestroy,
    Steps: []resource.TestStep{
            Config: testAccExampleResource,
            Check: testAccCheckExampleResourceExists,

See the TestCase documentation for more information on using resource.TestCase.