Generates a static html report based on pytest
framework
- Generic information
- Overview
- Trends
- Suite Highlights
- Test suite details
- Archives / History
- Screenshots on failure
- Test Rerun support
$ pip3 install pytest-html-reporter
By default, the filename used is pytest_html_reporter.html
and path chosen is report
; you can skip both or
either one of them if not needed:
$ pytest tests/
Custom path, filename, and title
Add --html-report
tag followed by path location and filename to customize the report location and filename:
$ pytest tests/ --html-report=./report $ pytest tests/ --html-report=./report/report.html
Add --title
tag followed by the report title:
$ pytest tests/ --html-report=./report --title='PYTEST REPORT'
Add --archive-count
tag followed by an integer to limit showing the number of builds in the Archives
section:
$ pytest tests/ --archive-count 7 $ pytest tests/ --html-report=./report --archive-count 7
pytest.ini
Alternate option is to add this snippet in the pytest.ini
file:
[pytest] addopts = -vs -rf --html-report=./report --title='PYTEST REPORT'
Note: If you fail to provide --html-report
tag, it consider your project's home directory as the base
Import attach
from the library and call it with the selenium command as given below:
from pytest_html_reporter import attach ... attach(data=self.driver.get_screenshot_as_png())
Yes, you can use this demo as an example, https://github.com/prashanth-sams/pytest-html-reporter:
$ pytest tests/functional/