Metadata-Version: 2.4
Name: robotframework-xlibrary-result
Version: 1.0.0
Summary: HTML report generator for Robot Framework — rich, self-contained reports with API logging, deep-diff, JSON Schema validation, image comparison, and screenshot annotation.
Author-email: Tassana Khrueawan <Tassana.khr@gmail.com>
Maintainer-email: Tassana Khrueawan <Tassana.khr@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Khrx1999/robotframework-xlibrary-result
Project-URL: Repository, https://github.com/Khrx1999/robotframework-xlibrary-result
Project-URL: Documentation, https://github.com/Khrx1999/robotframework-xlibrary-result#readme
Project-URL: Changelog, https://github.com/Khrx1999/robotframework-xlibrary-result/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/Khrx1999/robotframework-xlibrary-result/issues
Keywords: robotframework,robot-framework,test-automation,html-report,api-testing,screenshot,json-schema,test-reporting
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Robot Framework
Classifier: Framework :: Robot Framework :: Library
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Testing :: Acceptance
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: robotframework>=6.0
Requires-Dist: Jinja2>=3.0
Requires-Dist: MarkupSafe>=2.0
Requires-Dist: PyYAML>=6.0
Requires-Dist: Pillow>=9.0
Requires-Dist: numpy>=1.20
Requires-Dist: requests>=2.28
Provides-Extra: schema
Requires-Dist: jsonschema>=4.0; extra == "schema"
Provides-Extra: imaging
Requires-Dist: opencv-python>=4.5; extra == "imaging"
Requires-Dist: imageio>=2.20; extra == "imaging"
Provides-Extra: all
Requires-Dist: jsonschema>=4.0; extra == "all"
Requires-Dist: opencv-python>=4.5; extra == "all"
Requires-Dist: imageio>=2.20; extra == "all"
Provides-Extra: dev
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Dynamic: license-file

# robotframework-xlibrary-result

[![PyPI version](https://img.shields.io/pypi/v/robotframework-xlibrary-result.svg)](https://pypi.org/project/robotframework-xlibrary-result/)
[![Python versions](https://img.shields.io/pypi/pyversions/robotframework-xlibrary-result.svg)](https://pypi.org/project/robotframework-xlibrary-result/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Robot Framework](https://img.shields.io/badge/Robot%20Framework-6.0%2B-green.svg)](https://robotframework.org/)

> **Rich HTML reports for Robot Framework** — API request/response logging,
> deep-diff comparison viewer, JSON Schema validation, image comparison,
> and annotated screenshots, all in a single self-contained `test_result.html`.

## Installation

```bash
pip install robotframework-xlibrary-result
```

Optional feature groups:

```bash
pip install "robotframework-xlibrary-result[schema]"   # adds jsonschema for VALIDATE JSON SCHEMA
pip install "robotframework-xlibrary-result[imaging]"  # adds opencv + imageio for advanced image diff
pip install "robotframework-xlibrary-result[all]"      # everything
```

## Quick start (Robot Framework)

```robotframework
*** Settings ***
Library    robotframework_xlibrary_result.XLibraryResult
Library    RequestsLibrary

Suite Setup       Init Report
Suite Teardown    Finalise Report

*** Variables ***
${REPORT_PATH}    ${OUTPUT_DIR}/test_result.html
@{EXEC_RESULTS}   @{EMPTY}

*** Test Cases ***
TC01 — Get user list
    SET CURRENT TEST CASE ID    TC01
    APPEND STEP TITLE           execution
    ${resp}=    GET    https://api.example.com/users
    Append Request and Response to HTML Report
    ...    GET /users    PASS    request_data=${None}    response_data=${resp.json()}
    ...    http_method=GET    http_status_code=${resp.status_code}    url=${resp.url}
    Compare Dict to Dict    ${resp.json()}    {"status": "ok"}    Verify status field

*** Keywords ***
Init Report
    ${LIB}=    Get Library Instance    robotframework_xlibrary_result.XLibraryResult
    ${EMPTY}=  Create Dictionary
    Setup Generate HTML Report    ${LIB}    ${REPORT_PATH}    Demo Suite
    ...    ${EMPTY}    ${EMPTY}    Robot Framework user

Finalise Report
    Write Steps To HTML    ${REPORT_PATH}    PASS    ${EXEC_RESULTS}
```

## Quick start (pure Python)

```python
from robotframework_xlibrary_result import XLibraryResult, load_report_config

# Load config (falls back to bundled defaults/report.yaml when no project YAML exists)
config = load_report_config(".")
print(config["tool"]["name"])  # → "XLibrary Result"

xr = XLibraryResult()
xr.append_step_to_list(
    step_title="Sanity check",
    result="PASS",
    description="Library imports correctly.",
)
```

## What's in the report

| Feature | Keyword | Description |
|---|---|---|
| Test step log | `APPEND STEP TO HTML RESULT` | Title, status badge, duration bar, attachments |
| API request | `APPEND STEP REQUEST HTML RESULT` | Headers / body / cURL tabs, sensitive masking |
| Combined req+resp | `Append Request and Response to HTML Report` | Side-by-side, HTTP method/status badge |
| Dict diff | `Compare Dict to Dict` | 3-mode viewer (Table / JSON / Inline), ignore fields/paths |
| List diff | `Compare List of Dict to List of Dict` | Card-per-item with field-level diff |
| Schema validation | `VALIDATE JSON SCHEMA` | Draft-7, rich tree-style error rendering |
| Image diff | `xCompare Images` | Pixel / histogram / template / ORB algorithms |
| Screenshot | `Capture Screenshot` | Desktop + mobile (ADB / xcrun) + Flutter; auto-annotated |

## Configuration

The library searches for `CONFIG/REPORT_CONFIG/report.yaml` upwards from your
test file. If none is found, it falls back to the **bundled**
`defaults/report.yaml` inside the installed package — so it works
**out-of-the-box** with no setup.

Override only the keys you care about:

```yaml
project:
  name: "My Awesome API"
  logo: "https://example.com/logo.png"
  subtitle: "Smoke + regression"

tool:
  version: "v2.5.1"

footer:
  powered_by: "Powered by Robot Framework"
  copyright: "© {year} Acme Corp"

report:
  auto_open: true
  filename: "smoke_2025_q4"
```

See [`src/robotframework_xlibrary_result/defaults/report.yaml`](src/robotframework_xlibrary_result/defaults/report.yaml)
for the full schema with comments.

## Compatibility

* **Python**: 3.9 – 3.13
* **Robot Framework**: 6.0+
* **OS**: macOS, Linux, Windows

## Development

```bash
git clone https://github.com/Khrx1999/robotframework-xlibrary-result.git
cd robotframework-xlibrary-result
pip install -e ".[dev,all]"
pytest                              # smoke tests
ruff check src tests                # lint
python -m build                     # build sdist + wheel
```

## Publishing to PyPI

```bash
# Modern approach (recommended)
python -m build
twine upload --verbose dist/*

# Legacy approach (also supported)
python setup.py sdist bdist_wheel
twine upload --verbose dist/*
```

> 🔐 **Security tip**: store your token in `~/.pypirc` (chmod 600) or in your
> OS keyring — never paste it into a chat / commit / source file.

## Contributing

Contributions are welcome! Please open an issue first to discuss any
significant changes. For bug fixes, send a pull request directly with:

1. Failing test reproducing the bug.
2. Fix.
3. Test passing.

## License

MIT — see [LICENSE](LICENSE).

Copyright © 2026 **Tassana Khrueawan**.

## Origin

Originally extracted from the
[Automate V3](https://github.com/Khrx1999/Automate) internal Robot Framework
framework — refactored into a standalone, pip-installable library so the
wider community can benefit.
