Add message attribute to JUnit failure/error elements#49
Merged
Conversation
Surface a test result's :message as a dedicated `message` attribute on <failure> and <error> elements, instead of only embedding it in the CDATA body. <error> elements keep their existing `type` attribute alongside the new `message`. The attribute is omitted entirely when there is no message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Satisfies clj-kondo's warn-on-reflection lint and avoids reflection on the XMLStreamWriter interop calls. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates Hawk’s JUnit XML writer to expose a test result’s :message as a dedicated message attribute on <failure> and <error> elements (omitting the attribute when the message is nil), aligning with DEV-2250’s goal of making the message available without parsing CDATA output.
Changes:
- Add
messageattribute support for:fail(<failure>) and:error(<error>) assertion results. - Preserve existing
<error type="...">behavior while adding the newmessageattribute. - Add focused tests that exercise presence/absence of the new attribute for both failure and error cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/mb/hawk/junit/write.clj |
Adds conditional :message attribute emission for <failure> and <error> elements (keeping <error>’s existing type attribute). |
test/mb/hawk/junit/write_test.clj |
Adds tests validating message attribute inclusion/omission for both failure and error assertion result XML. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
For :error results, clojure.test sets a generic ":message" of "Uncaught exception, not in assertion.". The exception's own root-cause message is far more useful as the JUnit `message` attribute (e.g. for grouping/display in test analytics tools), so prefer it, falling back to clojure.test's message when `actual` is not a Throwable or the exception has no message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
nemanjaglumac
added a commit
to metabase/metabase
that referenced
this pull request
Jun 29, 2026
Prefer the message attribute on <failure>/<error> over guessing from the body. The body's first line is the file:line locator, not a message, so fall back to null rather than that. Forward-compatible with hawk emitting the attribute (metabase/hawk#49) and today's hawk that doesn't. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task
camsaul
approved these changes
Jul 2, 2026
camsaul
left a comment
Member
There was a problem hiding this comment.
this will do for now, let's get it in
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves DEV-2250
Surface a test result's :message as a dedicated
messageattribute on and elements, instead of only embedding it in the CDATA body. elements keep their existingtypeattribute alongside the newmessage. The attribute is omitted entirely when there is no message.