Module Testing Experiment documentation

Hello,

I’ve been trying recently the experimental module testing, with for instance the equal keyword with got and want, which I learnt from Terraform Documentation.
I was wondering if there was any other documentation available, for instance the list of possible keywords we can use?
Thanks in advance for your answer.

Hi @guilhem-martin,

With the current incarnation of the experiment, only the equal and check blocks shown in the documentation are supported. The example in the documentation seems to be exhaustive for the current capabillities of the test_assertions resource type.

There is no other documentation for these features other than what’s on that page, but if you have particular questions about it that aren’t covered in that documentation then I’m happy to try to answer them here. I’d also love to hear about your experience using these features, since any feedback will contribute to helping move this feature forward towards a final design.

Thanks!

Thanks @apparentlymart for your answer.

For my experience feedback so far:

  • It’s practical to use - easy to introduce on existing Terraform script
  • An output in a “classical” format would be a bonus - like JUnit output or Robot Framework output for instance, so that you can process the results
  • There could be specialized keywords such as AssertNotEqual, AssertIn - such as we have in Python unit test - it isn’t a killer feature but it helps to read the tests

Thanks for this testing module experiment.

Thanks for the feedback!

We didn’t mention it in the initial experiment docs because the initial focus area for this research was learning about what kinds of tests are viable to write in this way, rather than how this command might integrate into a pipeline, but it might interest you to know that the terraform test command has a --junit-xml=FILENAME option that will write the results in JUnit XML format.

Again since that wasn’t the focus of initial research I can’t promise it will be useful, but I mention it in case you’d like to try it and see if it’s compatible with the downstream software you usually use to consume and present test results. (The JUnit XML format doesn’t have any formal specification, so we just tried to follow the behavior of other software as closely as possible.)

2 Likes