Request for Testing: Terraform Test!

We just released Terraform v1.6.0-beta2!

Thanks everyone for your feedback so far, please keep it coming!

1 Like

what am i doing wrong here @liamcervante ? trying to use -filter

$ ./terraform test -filter=examples_ipam.tftest.hcl

Success! 0 passed, 0 failed.
$ ll tests/examples_ipam.tftest.hcl      
-rw-r--r-- 1 dm staff 213 Oct  3 14:03 tests/examples_ipam.tftest.hcl
$ cat -p tests/examples_ipam.tftest.hcl
run "ipam_setup" {
    command = apply
    module {
        source = "./tests/hcl_fixtures/ipam_base"
    }
}

run "validate_ipam_vpc" {
    command = apply
    module {
        source = "./examples/ipam"
    }
}
$ ./terraform -v   
Terraform v1.6.0-rc1
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.19.0
+ provider registry.terraform.io/hashicorp/awscc v0.61.0

$ ./terraform test                                 
tests/examples_ipam.tftest.hcl... in progress
...

Hi @dmullen, the filter flag accepts relative paths, so I think -filter=tests/examples_ipam.tftest.hcl should work. The argument as you have it would pick up a test file within the root configuration directory.

I’ll see if I can update the docs to be clearer.

Thanks!

Hi, I’m trying to get started with terraform test and have hit a stumbling block which I have posted about here: How do I pass provider information to tests?

Any help would be appreciated!

Hello,
is there a release ready documentation?

Hi @AZZ

Terraform v1.6.0 has now been released, with full documentation.

A good starting place would be here: Command: test | Terraform | HashiCorp Developer

We also have a Terraform language page on test files here: Tests - Configuration Language | Terraform | HashiCorp Developer

Hope these help!

@omarismail great timing with the terraform test-release - as I’m just in the middle of my master thesis evaluating Terraform test approaches: Quantitative Cost Assessment of IaC Testing :sweat_smile:

On a side note - if someone has input on how to improve my tests / test cases, that would be highly appreciated: code repo :wink:


Regarding static testing (unit testing), I was able to cover

I was not able to cover the following static unit test with terraform test (so I used pytest instead) - input would be welcome :wink::

The missing DCs idempotency (dc5), service (dc7) and syntax (dc8) do not really make sense in the context of static unit tests - I think?

Using terraform test for dynamic testing, I cover the following cases (overlap with static tests is intended to compare them):

I was not able to cover idempotency checks with terraform test and had to use terratest instead: idempotency check

I did not come up with dynamic test cases for documentation (dc4), security (dc6), service (dc7) or syntax (dc8) - especially input for security or service related test cases would be highly welcome :thinking: :sweat_smile:

Hey @hashicorp20 , great to see this is helping your master thesis. Wanted to share that we will be adding mocking capabilities in the next release, so that may also give you more tools for your research!

If you wanted to chat, feel free to email me at oismail@hashicorp.com and we can setup a time :).

1 Like