Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

How to Generate pytest-HTML Reports in CI and Share Them as Build Artifacts

Generate a pytest-html report at a predictable path, upload it through your CI provider, and check that the downloaded artifact includes any linked report files.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install pytest-html in the Python environment that runs your tests, write the report to a predictable path, then configure your CI provider to upload or collect that file. A self-contained report is convenient to download and share:

pytest --html=reports/pytest.html --self-contained-html

Generating the HTML does not publish it as a build artifact by itself. Your pipeline must explicitly collect the report, including after test failures if you need reports from failed runs.

As an Amazon Associate I earn from qualifying purchases.

Generate the report with pytest-html

pytest-html is a pytest plugin that generates an HTML report of test results. Install it in the same Python environment used to invoke pytest; adding it to the project’s normal or development dependencies helps keep local and CI environments consistent.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a stable output path and use that same path in your CI artifact configuration. The plugin’s user guide documents this command for a self-contained report:

pytest --html=reports/pytest.html --self-contained-html

Create the reports directory before running pytest if it does not already exist. Without --self-contained-html, report assets such as CSS and images are stored separately by default, so collect the report together with those assets.

Upload the report as a CI artifact

Artifact configuration is specific to the CI provider. The examples below use GitHub Actions and GitLab CI; in either case, the path must match the report’s output path.

GitHub Actions

Use the official actions/upload-artifact action and set its path input to the report file or its containing directory. For example, the relevant steps can be structured like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
- name: Run tests and generate HTML report
  run: pytest --html=reports/pytest.html --self-contained-html

- name: Upload pytest HTML report
  if: always()
  uses: actions/upload-artifact
  with:
    name: pytest-html-report
    path: reports/pytest.html

The if: always() condition makes the upload step eligible to run even when the test step fails. Check the behavior in your workflow, especially if other job-level conditions or cancellation affect execution. Artifact access and retention depend on repository and workflow settings; do not assume a report is public or retained indefinitely.

GitLab CI

GitLab collects files declared under a job’s artifacts:paths. For example:

test:
  script:
    - mkdir -p reports
    - pytest --html=reports/pytest.html --self-contained-html
  artifacts:
    when: always
    paths:
      - reports/pytest.html

In GitLab, when: always requests artifact collection regardless of job success or failure. Confirm how the job ends in your pipeline and consult the official job artifacts documentation for access and retention behavior, which depends on configuration.

Make sure the downloaded report is usable

A self-contained report embeds the ordinary report assets, which makes a single HTML file easier to download and share. It does not necessarily embed every file referenced by added report extras. The plugin warns when files or links are added to a self-contained report; screenshots and other linked resources may still need to be uploaded alongside the HTML file. If you use those extras, collect the referenced files or the whole directory and preserve their relative paths.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Run the workflow and open the artifact in the CI interface.
  2. Download it and open pytest.html locally.
  3. Check that the report renders and that any screenshots, linked files, or other extras you rely on are available.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Collect reports from failed test runs

Test commands commonly return a failure status when tests fail, and some CI configurations stop or skip later steps after that status. If you need a report for failed runs, configure artifact collection to run despite test failure using the provider’s appropriate syntax, then verify the failed-test path in your own pipeline. The GitHub Actions and GitLab examples above show provider-specific approaches; do not assume a successful upload merely because the report file was generated.

Keep HTML and test-result integrations distinct

The workflow here produces an HTML report through pytest-html. JUnit XML is a different output format and may be used by CI integrations that consume XML results; it is not a substitute for uploading the HTML file when readers need the pytest-html report. If your pipeline needs both, configure each output and artifact or integration separately.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.