terratest
terratest copied to clipboard
I want to generate a html report for terratest scripts. Like how many tests are Pass/Fail? If it is possible can you tell me how to do it?
terratest_log_parser generates a junit xml report which many CI systems will automatically render for you.
If you don't have anything handy, you can use something like https://gitlab.com/inorton/junit2html
Any hints on how to write our test case(s) file(s) to get more useful junit reports? I only get something like this
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite tests="1" failures="0" time="309.730" name="command-line-arguments">
<properties>
<property name="go.version" value="go1.13"></property>
</properties>
<testcase classname="command-line-arguments" name="TestAws" time="309.560"></testcase>
</testsuite>
</testsuites>
Right now I have one source file for the test cases, and it defines one function like
func TestAws(t *testing.T) {
terraformOptions := &terraform.Options{
TerraformDir: "..",
Vars: map[string]interface{}{
...
},
}
defer terraform.Destroy(t, terraformOptions)
terraform.InitAndApply(t, terraformOptions)
aws.AssertS3BucketExists(t, awsRegion, "expected_bucket_name")
dynamoTable := aws.GetDynamoDBTable(t, awsRegion, "expected_table_name")
assert.NotNil(t, dynamoTable)
}
I can infer that each func
which takes the t *testing.T
parameter translates to a testcase
in the report. But I don't want to apply and destroy the module I'm testing multiple times. I'm assuming I need to make use of test_structure here? Because if so, looking at examples terraform_gcp_ig_example_test.go you are indeed doing a fully apply and destroy.