Commit graph

3 commits

Author SHA1 Message Date
Samsondeen
1bd312f155
Produce detailed diagnostic objects when test run assertions fail (#36522) 2025-03-03 15:46:04 +01:00
Sarah French
6b81f7184c
Change JUnit terraform test output to include test failure details inside <failure> elements, use the error message as the message attribute (#36316)
* Add details to `<failure>` element describing which assertion failed

* Remove unused diagnostic string

* Set `message` attribute of `<failure>` element to failed assertion's error message

* Make `<failure>` contain diagnostic's message, refactor how `message` attribute is set

* Ensure that system-err is only added when needed

* Update test fixtures

* Make diags usage clearer, ensure all test failure diags in "failure" element

* Refactor how "skipped" element value is set

* Fix failing test Test_TestJUnitXMLFile_Save
2025-01-22 16:42:04 +00:00
Sarah French
ab6e4f2299
Refactor JUnit XML output of terraform test into a new junit package (#36304)
* Refactor JUnit XML output to use new concept of an Artifact

* Move JUnit-related code into new `artifact` package

* Refactor Artifact's Save method to return diagnostics, update comments

Previously TestJUnitXMLFile implemented the View interface, which cannot return errors. Now it's not a View any more we can simplify things.

* Make junitXMLTestReport output deterministic by iterating over a slice instead of a map, add test

* Provide sources to junitXMLTestReport, allowing complete error messages in the XML

We need to ensure that artifact.NewTestJUnitXMLFile is called once the config Loader is available as a non-nil pointer

* Whitespace

* Add some test coverage for JUnit XML output for `terraform test`

* Refactor how file is saved, add tests

* Move XML structs definitions outside of `junitXMLTestReport`

* Fix nil pointer bug

* Add missing file headers

* Refactor comparison of byte slices

* Rename package to `junit`, rename structs to match

* Add a test showing JUnit output when a test is skipped by the user
2025-01-13 13:25:58 +00:00