-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor JUnit XML output of terraform test
into a new junit
package
#36304
Conversation
Previously TestJUnitXMLFile implemented the View interface, which cannot return errors. Now it's not a View any more we can simplify things.
…e instead of a map, add test
…es in the XML We need to ensure that artifact.NewTestJUnitXMLFile is called once the config Loader is available as a non-nil pointer
view := views.NewTest(args.ViewType, c.View) | ||
var junitXMLView *views.TestJUnitXMLFile | ||
|
||
// The specified testing directory must be a relative path, and it must |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is being rendered in a confusing way. The change I made was to move the JUnit-related block (checking experimental status, setting up vars etc) to go underneath the block starting config, configDiags := c.loadConfigWithTests(".", args.TestDirectory)
. This is due to needing c.configLoader
to be a non-nil pointer when we call NewTestJUnitXMLFile
.
d8f69c7
to
872e950
Compare
4bbe97f
to
168df6a
Compare
Opening for review- I've left some comments via self-review and I've re-done this work so that the commits are clean and show the changes 'building up' over time instead of a big-bang refactor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks fine, just a nit around the naming of the new package. I think it could be a bit more descriptive than just artifact
.
terraform test
into a new artifact
packageterraform test
into a new junit
package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🎉
Thanks! |
This PR refactors code that allows users to create a JUnit XML output file describing the outcome of a
terraform test
command.Previously this feature was implemented as a Test View (i.e. the struct that managed reporting test outcomes to the terminal), see original comment here for context. This wasn't a good fit; the Test interface has several methods to allow continuous printing of updates to a terminal, whereas creating a JUnit output file requires waiting until all the tests are complete before preparing and saving the file.
This PR introduces the new interface
JUnit
which is a means through which a test run may create a file locally that summarises a test suite, after it's finished sending output to aView
. The JUnit output feature has been refactored to use this interface.Also, I've updated the JUnit output so that sources are available when creating parts of the XML file from diagnostics.
Future work not in this PR:
junitXMLTestReport
Target Release
1.11.x
CHANGELOG entry
This change is user-facing and I added a changelog entry.This change is not user-facing.This change is user-facing but is part of an experimental feature, so changelogs are not required