KaykCaputo / KaykCaputo/oracletrace

[Feature]: Add CLI integration test for --html export

Open Beginner friendly
#66 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Python
Stars
22
Forks
16
PR merge metrics
No merged PRs in 30d

Description

## Summary

Add a CLI integration test that verifies `--html` correctly exports an HTML report through the main command path.

## Problem

The HTML reporter has 7 unit tests in `tests/test_html_reporter.py`, but the CLI wiring in `_export_results()` is untested. `test_main_runs_trace_and_exports_json_and_csv` covers JSON and CSV, but there is no equivalent for `--html`.

## Proposed Solution

Add `test_main_runs_trace_and_exports_html` to `tests/test_cli.py` using the existing `FakeTracer` + `_run_cli` pattern:

- Pass `--html` with a `tmp_path` output file
- Assert exit code `0`
- Assert the HTML file exists and contains `` and `OracleTrace Report`
- Optionally assert stdout contains `HTML report generated:`

## Use Case

Prevents regressions in CLI argument parsing, export ordering, or the success message for HTML output — a path users rely on for interactive trace inspection.

## Example (optional)

```bash
# Covered by the new test (mocked CLI invocation)
oracletrace app.py --html report.html
```

```text
HTML report generated: /path/to/report.html
```

## Alternatives Considered

- End-to-end test running a real script without mocks — heavier and slower; mocked CLI tests match existing conventions.
- Extending `test_main_runs_trace_and_exports_json_and_csv` to also cover HTML — possible, but a dedicated test keeps failures easier to diagnose.

## Additional Context

Relevant files:
- `oracletrace/cli.py` — `_export_results()` (lines 122–124)
- `tests/test_cli.py` — `test_main_runs_trace_and_exports_json_and_csv` as template
- `tests/test_html_reporter.py` — HTML content assertions to reuse

## Checklist

- [x] I searched existing issues before opening this request
- [x] I described the problem and why this feature is useful
- [x] I provided enough detail for implementation discussion

Contributor guide

Open the contributing guide

Research direction

Start with tests/test_cli.py and the existing test_main_runs_trace_and_exports_json_and_csv, then inspect oracletrace/cli.py at _export_results() and the HTML assertions in tests/test_html_reporter.py. Follow the existing FakeTracer and _run_cli pattern with a tmp_path output. Done means the CLI test exits with code 0, creates the HTML file, and verifies the expected doctype and report title.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.