Skip to content

Add Junix XML export for SuiteResult#2352

Merged
kevinmessiaen merged 7 commits intoGiskard-AI:mainfrom
Mapalo90:feat/suite-result-junit-xml
Apr 3, 2026
Merged

Add Junix XML export for SuiteResult#2352
kevinmessiaen merged 7 commits intoGiskard-AI:mainfrom
Mapalo90:feat/suite-result-junit-xml

Conversation

@Mapalo90
Copy link
Copy Markdown
Contributor

@Mapalo90 Mapalo90 commented Apr 1, 2026

Description

Adds native JUnit XML export for SuiteResult using only xml.etree.ElementTree.

This PR introduces:

  • giskard.checks.export.junit.to_junit_xml
  • SuiteResult.to_junit_xml(...) convenience method
  • JUnit XML mapping aligned with maintainer feedback:
    • SuiteResult -> <testsuite>
    • ScenarioResult -> <testcase>
  • scenario-level assertion counts
  • final_trace and step payloads as properties
  • metrics as JUnit properties
  • failure / error / skipped mapping at the scenario level
  • timing information
  • tests for XML structure, file output, metrics, and convenience method

Validation:

  • uv run pytest libs/giskard-checks/tests/export/test_junit.py -q
  • uv run pytest libs/giskard-checks/tests -q

Related Issue

Closes #2345

Type of Change

  • 📚 Examples / docs / tutorials / dependencies update
  • 🔧 Bug fix (non-breaking change which fixes an issue)
  • 🥂 Improvement (non-breaking change which improves an existing feature)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🔐 Security fix

Checklist

  • I've read the CODE_OF_CONDUCT.md document.
  • I've read the CONTRIBUTING.md guide.
  • I've written tests for all new methods and classes that I created.
  • I've written the docstring in Google format for all the methods and classes that I used.
  • I've updated the pdm.lock running pdm update-lock (only applicable when pyproject.toml has been
    modified)

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to export test suite results to JUnit XML format, adding a to_junit_xml method to the SuiteResult class and implementing the export logic in a new module. The implementation includes detailed mapping of scenario results, checks, and metrics to standard JUnit elements. Review feedback identifies opportunities to improve the generated XML by removing redundant step data in failure details and reducing file size by avoiding duplicate JSON payloads across the properties and system-out sections.

Comment thread libs/giskard-checks/src/giskard/checks/export/junit.py Outdated
Comment thread libs/giskard-checks/src/giskard/checks/export/junit.py Outdated
@Mapalo90
Copy link
Copy Markdown
Contributor Author

Mapalo90 commented Apr 1, 2026

Updated the XML mapping to follow maintainer feedback: SuiteResult now maps to a single <testsuite> and each ScenarioResult maps to a <testcase>.

@Mapalo90 Mapalo90 changed the title Junix XML Export for SuiteResult Add Junix XML Export for SuiteResult Apr 1, 2026
@Mapalo90
Copy link
Copy Markdown
Contributor Author

Mapalo90 commented Apr 1, 2026

I addressed the review feedback in f7492a6 by removing duplicated payloads from failure details/system-out while keeping the structured data in <properties>. Local validation still passes:

  • uv run pytest libs/giskard-checks/tests/export/test_junit.py -q
  • uv run pytest libs/giskard-checks/tests -q

When convenient, could a maintainer add the safe for build label so the required workflows can run?

@kevinmessiaen kevinmessiaen self-requested a review April 1, 2026 07:58
Copy link
Copy Markdown
Member

@kevinmessiaen kevinmessiaen left a comment

Choose a reason for hiding this comment

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

Thanks for your first contribution to Giskard!

Looking good, however there is a small issue with having duplicated data in the report.

I also left some comments on how we could improve the outputs display while reusing already existing code.

@@ -0,0 +1,222 @@
from __future__ import annotations
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.

from __future__ import annotations is unnecessary with 3.12+

Suggested change
from __future__ import annotations

Comment thread libs/giskard-checks/tests/export/test_junit.py Outdated
Comment thread libs/giskard-checks/tests/export/test_junit.py Outdated
Comment thread libs/giskard-checks/src/giskard/checks/export/junit.py Outdated
@Mapalo90 Mapalo90 changed the title Add Junix XML Export for SuiteResult JUnit Apr 1, 2026
@Mapalo90 Mapalo90 changed the title JUnit Add JUnit XML export for SuiteResult Apr 1, 2026
@Mapalo90
Copy link
Copy Markdown
Contributor Author

Mapalo90 commented Apr 1, 2026

Hi again, thanks for the feedback. I pushed 16ec1b4, which removes the __future__ imports, drops the TestCaseResult alias and switches system-out to the existing rich scenario report output. Local tests still pass. When you have a moment, could you take another look?

@Mapalo90 Mapalo90 requested a review from kevinmessiaen April 1, 2026 12:29
@Mapalo90 Mapalo90 changed the title Add JUnit XML export for SuiteResult Add Junix XML export for SuiteResult Apr 1, 2026
Copy link
Copy Markdown
Member

@kevinmessiaen kevinmessiaen left a comment

Choose a reason for hiding this comment

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

This looks good to me. Thanks for the quick changes!

The CI is failing because of the linter, you can fix it with make format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Add JUnit XML export for SuiteResult

2 participants