Skip to content

Tyrrrz/GitHubActionsTestLogger

master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.

GitHub Actions Test Logger

Made in Ukraine Build Coverage Version Downloads Discord Donate Fuck Russia

🟢 Project status: active[?]

Custom logger for dotnet test that integrates with GitHub Actions. When using this logger, failed tests are listed in job annotations and highlighted in code diffs. Additionally, this logger also generates a job summary that contains detailed information about the executed test run.

Terms of use[?]

By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You reject false narratives perpetuated by Russian state propaganda

To learn more about the war and how you can help, click here. Glory to Ukraine! 🇺🇦

Install

  • 📦 NuGet: dotnet add package GitHubActionsTestLogger

Screenshots

annotations summary

Usage

Installation

To use GitHub Actions Test Logger, follow these steps:

  1. Install GitHubActionsTestLogger package in your test project
  2. Update Microsoft.NET.Test.Sdk package in your test project to the latest version
  3. Modify your GitHub Actions workflow file by adding --logger GitHubActions to dotnet test:
name: CI
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install .NET
        uses: actions/setup-dotnet@v2
        with:
          dotnet-version: 6.0.x

      - name: Build & test
        run: dotnet test --configuration Release --logger GitHubActions

Warning: Ensure that your test project references Microsoft.NET.Test.Sdk version 17.2.0 or higher. Older versions of this package may not work properly with custom test loggers.

Warning: If you are using .NET SDK v2.2 or lower, you need to enable <CopyLocalLockFileAssemblies> property in your test project.

Options

GitHub Actions Test Logger has options that you can override to customize its behavior. In order to pass an option to the logger, include it as an additional parameter inside --logger:

dotnet test --logger "GitHubActions;annotations.titleFormat=$test;annotations.messageFormat=$error"

annotations.titleFormat

Specifies the format of the annotation title used when reporting test failures.

The following replacement tokens are available:

  • $test — replaced with the display name of the test
  • $traits.TRAIT_NAME — replaced with the value of the trait named TRAIT_NAME
  • $error — replaced with the error message
  • $trace — replaced with the stack trace
  • $framework — replaced with the target framework

Default: $test.

Examples:

  • $testMyTests.Test1
  • [$traits.Category] $test[UI Tests] MyTests.Test1
  • $test ($framework)MyTests.Test1 (.NETCoreApp,Version=v6.0)

annotations.messageFormat

Specifies the format of the annotation message used when reporting test failures. Supports the same replacement tokens as annotations.titleFormat.

Default: $error.

Examples:

  • $errorAssertionException: Expected 'true' but found 'false'
  • $error\n$traceAssertionException: Expected 'true' but found 'false', followed by stacktrace on the next line