Skip to content

Add message attribute to JUnit failure/error elements#49

Merged
camsaul merged 3 commits into
mainfrom
junit-message-attr
Jul 2, 2026
Merged

Add message attribute to JUnit failure/error elements#49
camsaul merged 3 commits into
mainfrom
junit-message-attr

Conversation

@nemanjaglumac

@nemanjaglumac nemanjaglumac commented Jun 29, 2026

Copy link
Copy Markdown
Member

Resolves DEV-2250

Surface a test result's :message as a dedicated message attribute on and elements, instead of only embedding it in the CDATA body. elements keep their existing type attribute alongside the new message. The attribute is omitted entirely when there is no message.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 message attribute support for :fail (<failure>) and :error (<error>) assertion results.
  • Preserve existing <error type="..."> behavior while adding the new message attribute.
  • 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 nemanjaglumac requested a review from iethree June 29, 2026 18:49
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>

@camsaul camsaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will do for now, let's get it in

@camsaul camsaul merged commit e2f921c into main Jul 2, 2026
2 checks passed
@camsaul camsaul deleted the junit-message-attr branch July 2, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants