Skip to content

GitHub Action to run .NET Core tests and generate report attached to Workflow Run

License

Notifications You must be signed in to change notification settings

zyborg/dotnet-tests-report

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

dotnet-tests-report

GitHub Action to run .NET tests and generate reports and badges.

⭐ I appreciate your star, it helps me decide to which OSS projects I should allocate my spare time.


GitHub Workflow - CI GitHub release (latest by date)


This Action can be used to execute .NET tests using unit testing frameworks such as xUnit, NUnit and MSTest within a GitHub Workflow, as well as generate a Report from the tests results and attach it to the Workflow Run as a Check Run.

Check out the usage below.

Samples

Here we see some badges generated along with some Gist-based Tests Reports as part of a GitHub Workflow associated with this project.

  • XUnit Tests
  • NUnit Tests
  • MSTest Tests

And here are some samples of the actual generated reports:

Badges:

Workflow Reports:
Gist Reports:

Usage

Check out action.yml for full usage details. Here are some samples.

This is a basic example, that just provides a path to a single test project, and specifies the report name and title.

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: use this action, test solution dir
        uses: zyborg/dotnet-tests-report@v1
        with:
          project_path: tests/My.Project.Tests
          report_name: my_project_tests
          report_title: My Project Tests
          github_token: ${{ secrets.GITHUB_TOKEN }}

In this example, a Gist-based report is generated along with the one that is attached to the Workflow Run. Additionally, we request a Badge be generated that shows the number of passed tests out of the total number of tests found. We do this for each of two separate unit test projects.

jobs:
  test:
    runs-on: ubuntu-latest
    steps:

      - name: unit tests for Contoso Business Layer
        uses: zyborg/dotnet-tests-report@v1
        with:
          project_path: tests/Contoso.Business.Tests
          report_name: contoso_business_tests
          report_title: Contos Business Tests
          github_token: ${{ secrets.GITHUB_TOKEN }}
          gist_name: contoso_business_tests.md
          gist_badge_label: 'Contoso Business: %Counters_passed%/%Counters_total%'
          gist_token: ${{ secrets.GIST_TOKEN }}

      - name: unit tests for Contoso Service Layer
        uses: zyborg/dotnet-tests-report@v1
        with:
          project_path: tests/Contoso.Service.Tests
          report_name: contoso_service_tests
          report_title: Contos Service Tests
          github_token: ${{ secrets.GITHUB_TOKEN }}
          gist_name: contoso_service_tests.md
          gist_badge_label: 'Contoso Service: %Counters_passed%/%Counters_total%'
          gist_token: ${{ secrets.GIST_TOKEN }}

Set check status based on test outcome

By default the check status is set to 'neutral'. Set the flag set_check_status_from_test_outcome: true. Note that setting this flag to true will fail the check on pull requests if at least one test fails in your project.

PowerShell GitHub Action

This Action is implemented as a PowerShell GitHub Action.