Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

publish-unit-test-result-action

> 测试质量
Open source

GitHub Action to publish unit test results on GitHub

748 stars0 likes7 views
WebsiteGitHub

About

GitHub Action to publish unit test results on GitHub

GitHub Action to Publish Test Results

This GitHub Action analyses test result files and publishes the results on GitHub. It supports JSON (Dart, Mocha), TRX (MSTest, VS) and XML (JUnit, NUnit, XUnit) file formats, and runs on Linux, macOS and Windows.

You can use this action with runners (e.g. runs-on: ubuntu-latest) or self-hosted runners that support Docker:

yaml
- name: Publish Test Results
  uses: EnricoMi/publish-unit-test-result-action@v2
  if: (!cancelled())
  with:
    files: |
      test-results/**/*.xml
      test-results/**/*.trx
      test-results/**/*.json

See the notes on running this action with absolute paths if you cannot use relative test result file paths.

Use this for (e.g. runs-on: macos-latest) runners (no Docker needed):

yaml
- name: Publish Test Results
  uses: EnricoMi/publish-unit-test-result-action/macos@v2
  if: (!cancelled())
  with:
    files: …

… and (e.g. runs-on: windows-latest) runners (no Docker needed):

yaml
- name: Publish Test Results
  uses: EnricoMi/publish-unit-test-result-action/windows@v2
  if: (!cancelled())
  with:
    files: …

For Windows without PowerShell installed, there is the Bash shell variant:

yaml
- name: Publish Test Results
  uses: EnricoMi/publish-unit-test-result-action/windows/bash@v2
  if: (!cancelled())
  with:
    files: …

For self-hosted Linux GitHub Actions runners without Docker installed, please use:

yaml
- name: Publish Test Results
  uses: EnricoMi/publish-unit-test-result-action/linux@v2
  if: (!cancelled())
  with:
    files: …

See the notes on running this action as a non-Docker action.

If you see the "Resource not accessible by integration" error, you have to grant additional permissions, or setup the support for pull requests from fork repositories and branches created by Dependabot.

The if: (!cancelled()) clause guarantees that this action always runs, even if earlier steps (e.g., the test step) in your workflow fail, but not if the workflow was cancelled.

When run multiple times in one workflow, the option check_name has to be set to a unique value for each instance. Otherwise, the multiple runs overwrite each other's results.

Note: By default, this action does not fail if tests failed. This can be configured via action_fail. The action that executed the tests should fail on test failure. The published results however indicate failure if tests fail or errors occur, which can be configured via fail_on.

Thanks to the provided typings, it is possible to use this action in a type-safe way using GitHub Workflows Kt, which allows writing workflow files using a type-safe Kotlin DSL.

Permissions

Minimal workflow job permissions required by this action in public GitHub repositories are:

yaml
permissions:
  checks: write
  pull-requests: write

The following permissions are required in private GitHub repos:

yaml
permissions:
  contents: read
  issues: read
  checks: write
  pull-requests: write

With comment_mode: off, the pull-requests: write permission is not needed.

Generating test result files

Supported test result files can be generated by many test environments. Here is a small overview, by far not complete. Check your favorite development and test environment for its JSON, TRX file or JUnit, NUnit, XUnit XML file support.

|Test Environment |Language| JUnit XML | NUnit XML | XUnit XML | TRX file | JSON

file | |-----------------|:------:|:---------:|:---------:|:---------:|:---:|:---:| |Dart|Dart, Flutter| | | | |:white_check_mark:| |Jest|JavaScript|:white_check_mark:| | | | | |Maven|Java, Scala, Kotlin|:white_check_mark:| | | | | |Mocha|JavaScript|:white_check_mark:| |not xunit| |:white_check_mark:| |MStest / dotnet|.Net|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:| | |pytest|Python|:white_check_mark:| | | | | |sbt|Scala|:white_check_mark:| | | | | |Your favorite environment|Your favorite language|probably :white_check_mark:| | | | |

What is new in version 2

These changes have to be considered when moving from version 1 to version 2:

Default value for check_name changed

Unless check_name is set in your config, the check name used to publish test results changes from "Unit Test Results" to "Test Results".

Impact: The check with the old name will not be updated once moved to version 2.

Workaround to get version 1 behaviour: Add check_name: "Unit Test Results" to your config.

Default value for comment_title changed

Unless comment_title or check_name are set in your config, the title used to comment on open pull requests changes from "Unit Test Results" to "Test Results".

Impact: Existing comments with the old title will not be updated once moved to version 2, but a new comment is created.

Workaround to get version 1 behaviour: See workaround for check_name.

Modes create new and update last removed for option comment_mode

The action always updates an earlier pull request comment, which is the exact behaviour of mode update last. The configuration options create new and update last are therefore removed.

Impact: An existing pull request comment is always updated.

Workaround to get version 1 behaviour: Not supported.

Option hiding_comments removed

The action always updates an earlier pull request comment, so hiding comments is not required anymore.

Option comment_on_pr removed

Option comment_on_pr has been removed.

Workaround to get version 1 behaviour: Set comment_mode to always (the default) or off.

Publishing test results

Test results are published on GitHub at various (configurable) places:

  • as a comment in related pull requests
  • as a check in the checks section of a commit and related pull requests
  • as annotations in the checks section and changed files section of a commit and related pull requests
  • as a job summary of the GitHub Actions workflow
  • as a check summary in the GitHub Actions section of the commit

Pull request comment

A comment is posted on pull requests related to the commit.

In presence of failures or errors, the comment links to the respective check summary with failure details.

Subsequent runs of the action will update this comment. You can access earlier results in the comment edit history:

The result distinguishes between tests and runs. In some situations, tests run multiple times, e.g. in different environments. Displaying the number of runs allows spotting unexpected changes in the number of runs as well.

When tests run only a single time, no run information is displayed. Results are then shown differently then:

The change statistics (e.g. 5 tests ±0) might sometimes hide test removal. Those are highlighted in pull request comments to easily spot unintended test removal:

Note: This requires check_run_annotations to be set to all tests, skipped tests.

Comments can be disabled with comment_mode: off.

Commit and pull request checks

The checks section of a commit and related pull requests list a short summary (here 1 fail, 1 skipped, …), and a link to the check summary in the GitHub Actions section (here Details):

Commit checks:

Pull request checks:

Check runs can be disabled with check_run: false.

Commit and pull request annotations

Each failing test produces an annotation with failure details in the checks section of a commit:

and the changed files section of related pull requests:

Note: Annotations for test files are only supported when test file paths in test result files are relative to the repository root. Use option test_file_prefix to add a prefix to, or remove a prefix from these file paths. See Configuration section for details.

Note: Only the first failure of a test is shown. If you want to see all failures, set report_individual_runs: "true".

Check run annotations can be disabled with ignore_runs: true.

GitHub Actions job summary

The results are added to the job summary page of the workflow that runs this action:

In presence of failures or errors, the job summary links to the respective check summary with failure details.

Note: Job summary requires GitHub Actions runner v2.288.0 or above.

Job summaries can be disabled with job_summary: false.

GitHub Actions check summary of a commit

Test results are published in the GitHub Actions check summary of the respective commit:

Check runs can be disabled with check_run: false.

The symbols

The symbols have the following meaning:

Symbol Meaning
:white_check_mark: A successful test or run
A skipped test or run
A failed test or run
An erroneous test or run
The duration of all tests or runs

Note: For simplicity, "disabled" tests count towards "skipped" tests.

Configuration

Files can be selected via the files option. It supports glob wildcards like *, **, ?, and [] character ranges. The ** wildcard matches all files and directories recursively: ./, ./*/, ./*/*/, etc.

You can provide multiple file patterns, one pattern per line. Patterns starting with ! exclude the matching files. There have to be at least one pattern starting without a !:

yaml
with:
  files: |
    *.xml
    !config.xml

The list of most notable options:

Option Default Value Description
files no default File patterns of test result files. Relative paths are known to work best, while the non-Docker action also works with absolute paths. Supports *, **, ?, and [] character ranges. Use multiline string for multiple patterns. Patterns starting with ! exclude the matching files. There have to be at least one pattern starting without a !.
check_name "Test Results" An alternative name for the check result. Required to be unique for each instance in one workflow.
comment_title same as check_name An alternative name for the pull request comment.
comment_mode always The action posts comments to pull requests that are associated with the commit. Set to:
`a

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythongithub-actionsreportingtesting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.