Skip to content

feat: add HTML report exporter for SuiteResult#48

Merged
aviralgarg05 merged 1 commit into
aviralgarg05:mainfrom
anshiky73-svg:feature/html-report-exporter
Dec 27, 2025
Merged

feat: add HTML report exporter for SuiteResult#48
aviralgarg05 merged 1 commit into
aviralgarg05:mainfrom
anshiky73-svg:feature/html-report-exporter

Conversation

@anshiky73-svg
Copy link
Copy Markdown
Contributor

@anshiky73-svg anshiky73-svg commented Dec 24, 2025

Description

This PR introduces a self-contained HTML report exporter for SuiteResult, allowing users to generate a browser-viewable report of AgentUnit runs.

The HTML report complements existing JSON, Markdown, and JUnit exporters and provides a human-friendly summary of results, including scenario success rates and overall execution details.

Fixes #29

Type of Change

Please delete options that are not relevant:

  • New feature (non-breaking change which adds functionality)

Changes Made

Added an HTML exporter under agentunit.reporting

Introduced SuiteResult.to_html(path) API for generating reports

Generated self-contained HTML with:

Execution summary (duration, total runs)

Scenario-wise success rates

Inline visual pass/fail chart (no external dependencies)

Ensured implementation follows existing exporter patterns and project style guidelines

Testing

Please describe the tests you ran to verify your changes:

  • Existing test suite passes (pytest)
  • Added new tests for new functionality
  • Manual testing performed
  • Tested with multiple Python versions (3.10, 3.11, 3.12)
  • Some tests require optional dependencies (scipy, jsonschema) which were not installed in the local Windows + Python 3.14 environment. Lint checks passed and CI is expected to cover the full dependency matrix.

Test Configuration

  • Python version: 3.14.0
  • Operating System: Windows 11
  • Relevant adapters tested: Core reporting functionality

Test Results

ruff check .  -> All checks passed
ruff format . -> No formatting issues
pytest        -> Core tests passed; failures limited to tests requiring optional dependencies

Code Quality

  • My code follows the project's style guidelines (Ruff, Black)
  • I have run pre-commit run --all-files and addressed any issues
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added type hints where appropriate
  • I have updated docstrings following Google style

Documentation

  • I have updated relevant documentation (README, docs/, inline comments)
  • I have added/updated docstrings for new/modified functions
  • I have updated CHANGELOG.md under [Unreleased]
  • I have added examples if introducing new features

Breaking Changes

If this PR introduces breaking changes, please describe:

  • What breaks: N/A
  • Migration path for users: N/A
  • Deprecation warnings added (if applicable):N/A

Dependencies

  • No new dependencies added
  • New dependencies added (list below with justification)

Performance Impact

Describe any performance implications:

  • No performance impact
  • Performance improvement (describe and provide benchmarks)
  • Potential performance regression (describe and justify)

Screenshots/Recordings (if applicable)

N/A (HTML output can be generated locally via SuiteResult.to_html("report.html")

Additional Context

Add any other context about the PR here:

This feature aligns with existing exporter patterns (to_json, to_markdown, to_junit)

The HTML output is fully offline and dependency-free

Future enhancements could include richer charts or per-run details

Checklist

  • I have read the CONTRIBUTING.md guide
  • My branch name follows the convention (feature/, fix/, docs/, etc.)
  • My commit messages follow the conventional commit format
  • I have tested my changes locally
  • I have updated the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • All new and existing tests pass
  • I have checked for security vulnerabilities in any new dependencies

Reviewer Notes

Please pay special attention to:

  • HTML exporter structure and placement under agentunit.reporting
  • API consistency with existing exporters

Post-Merge Tasks

Tasks to complete after merging (if any):

  • Update external documentation
  • Announce in discussions/community
  • Create follow-up issues for future work

OPEN SOURCE PROGRAM KWOC

Summary by CodeRabbit

  • New Features
    • HTML report export capability added for test results
    • Reports display per-scenario metrics with visual pass/fail indicators
    • Summary statistics include total runs, passed/failed counts, and execution duration

✏️ Tip: You can customize this high-level summary in your review settings.

@continue
Copy link
Copy Markdown

continue Bot commented Dec 24, 2025

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts


Unsubscribe from All Green comments

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 24, 2025

Walkthrough

A new HTML reporting module is introduced with a render_html_report() function that generates complete HTML documents with inline CSS and scenario metrics tables from SuiteResult data. The SuiteResult class gains a to_html() method that renders and writes HTML reports to disk.

Changes

Cohort / File(s) Summary
HTML Report Generation
src/agentunit/reporting/html.py
New module with render_html_report() function that computes suite metrics (total/passed/failed runs, duration), iterates over scenarios to build table rows with escaped names, and returns a complete self-contained HTML document with inline CSS and skeleton bars for run visualizations. Uses TYPE_CHECKING to avoid runtime imports of SuiteResult.
HTML Export Method
src/agentunit/reporting/results.py
Adds to_html(path: str | Path) -> Path method to SuiteResult class that creates required directories, invokes render_html_report(self) to generate HTML content, writes to target path, and returns the path. Includes new import of render_html_report from reporting.html module.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements the core requirements from #29: SuiteResult.to_html() method [#29], self-contained HTML output [#29], and summary stats with per-scenario metrics [#29], but does not include interactive charts or formal HTML structure tests. Add implementation of interactive charts and comprehensive tests validating HTML structure to fully meet #29 acceptance criteria for charts and verified HTML output.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: add HTML report exporter for SuiteResult' clearly and concisely summarizes the main change: adding an HTML exporter for reports.
Description check ✅ Passed The PR description covers key sections including type of change, changes made, testing summary, and code quality checklist, providing sufficient detail about the HTML exporter implementation.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the HTML exporter feature objective: new html.py module for rendering, and to_html() method on SuiteResult for export functionality.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/agentunit/reporting/html.py (2)

87-88: Consider adding accessibility attributes to the bar chart.

The visualization bars are purely visual <div> elements without text content or ARIA attributes, making them inaccessible to screen readers. While the text summary above provides the information, adding semantic meaning to the bars would improve accessibility.

🔎 Suggested enhancement

Add ARIA attributes and/or text content to the bars:

-<div class="bar passed"></div>
-<div class="bar failed"></div>
+<div class="bar passed" role="img" aria-label="Passed: {passed_runs} out of {total_runs} runs">Passed: {passed_runs}</div>
+<div class="bar failed" role="img" aria-label="Failed: {failed_runs} out of {total_runs} runs">Failed: {failed_runs}</div>

This makes the visualization understandable to screen reader users and provides text alternatives.


34-35: Add viewport meta tag for better mobile rendering.

Including a viewport meta tag would improve the report's display on mobile devices.

🔎 Suggested addition
 <head>
   <meta charset="UTF-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>AgentUnit Report</title>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08d2f9e and c734eea.

📒 Files selected for processing (2)
  • src/agentunit/reporting/html.py
  • src/agentunit/reporting/results.py
🧰 Additional context used
🧬 Code graph analysis (2)
src/agentunit/reporting/results.py (1)
src/agentunit/reporting/html.py (1)
  • render_html_report (11-102)
src/agentunit/reporting/html.py (1)
src/agentunit/reporting/results.py (2)
  • SuiteResult (72-141)
  • success_rate (42-45)
🔇 Additional comments (3)
src/agentunit/reporting/results.py (1)

12-13: LGTM! Clean implementation following existing patterns.

The import and to_html() method follow the established pattern of other exporters in this file. The implementation is consistent with to_json(), to_markdown(), and to_junit() methods: creates parent directories, generates content via dedicated renderer, writes UTF-8 encoded output, and returns the Path.

Also applies to: 133-141

src/agentunit/reporting/html.py (2)

1-8: LGTM! Proper handling of imports.

The use of TYPE_CHECKING correctly avoids circular imports while maintaining type safety, and importing html.escape demonstrates good security practices for rendering user-controlled content.


11-30: LGTM! Solid computation and escaping.

The metrics computation is accurate, and the use of html.escape() for scenario names properly prevents XSS vulnerabilities. The row generation logic correctly formats all data for HTML output.

Comment on lines +62 to +68
.passed {{
background-color: #4CAF50;
width: {passed_runs * 20}px;
}}
.failed {{
background-color: #F44336;
width: {failed_runs * 20}px;
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Dec 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Bar chart width calculation creates UX issues with larger test suites.

The fixed-pixel width calculation (passed_runs * 20px) causes horizontal scrolling when test suites have many runs. For example, a suite with 100 test runs produces 2000px-wide bars, making the report difficult to view. Consider using percentage-based widths or a capped maximum width with proportional scaling.

🔎 Proposed fix using percentage-based widths

Modify the CSS and HTML to use a container with proportional bars:

     .bar {{
-      height: 18px;
+      display: inline-block;
+      height: 20px;
       margin: 6px 0;
+      color: white;
+      padding: 2px 8px;
+      font-size: 0.85em;
     }}
+    .bar-container {{
+      display: flex;
+      width: 100%;
+      max-width: 600px;
+      margin: 12px 0;
+    }}
     .passed {{
       background-color: #4CAF50;
-      width: {passed_runs * 20}px;
     }}
     .failed {{
       background-color: #F44336;
-      width: {failed_runs * 20}px;
     }}

And update the HTML section:

 <h2>Summary</h2>
 <p>Passed: {passed_runs} · Failed: {failed_runs}</p>

-<div class="bar passed"></div>
-<div class="bar failed"></div>
+<div class="bar-container">
+  <div class="bar passed" style="flex: {passed_runs}">Passed: {passed_runs}</div>
+  <div class="bar failed" style="flex: {failed_runs}">Failed: {failed_runs}</div>
+</div>

This approach uses flexbox to proportionally distribute space and includes text labels within the bars.

Also applies to: 87-88

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@anshiky73-svg pls fix this issue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok i will fix this issue @aviralgarg05

@anshiky73-svg
Copy link
Copy Markdown
Contributor Author

Hi @aviralgarg05 , i have created this please review it and merge it or recommend changes if required . I am a participating in kwoc so please add it as a kwoc contributer.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/agentunit/reporting/html.py 0.00% 13 Missing ⚠️
src/agentunit/reporting/results.py 0.00% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Owner

@aviralgarg05 aviralgarg05 left a comment

Choose a reason for hiding this comment

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

LGTM!

@aviralgarg05 aviralgarg05 merged commit 584d96f into aviralgarg05:main Dec 27, 2025
12 checks passed
@anshiky73-svg
Copy link
Copy Markdown
Contributor Author

hi @aviralgarg05 thanks for merging this PR , but my KWOC student profile still says 0 commits and 0 PR , what can be done about this to solve this issue as 31 dec is the time for mid evaluation

@aviralgarg05
Copy link
Copy Markdown
Owner

hi @aviralgarg05 thanks for merging this PR , but my KWOC student profile still says 0 commits and 0 PR , what can be done about this to solve this issue as 31 dec is the time for mid evaluation

I think that would get shown in a few minutes, because I had already merged pr's for kwoc for this project and it shows for them

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HTML report exporter with charts

3 participants