GitHubActionsTestLogger
GitHubActionsTestLogger copied to clipboard
.NET test logger that reports to GitHub Actions
GitHub Actions Test Logger
π‘ Project status: maintenance mode[?]
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
Usage
Installation
To use GitHub Actions Test Logger, follow these steps:
- Install GitHubActionsTestLogger package in your test project
- Update Microsoft.NET.Test.Sdk package in your test project to the latest version
- Modify your GitHub Actions workflow file by adding
--logger GitHubActions
todotnet 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 set the
<CopyLocalLockFileAssemblies>
property totrue
in your test project. Learn more.
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 namedTRAIT_NAME
-
$error
β replaced with the error message -
$trace
β replaced with the stack trace -
$framework
β replaced with the target framework
Default: $test
.
Examples:
-
$test
βMyTests.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:
-
$error
βAssertionException: Expected 'true' but found 'false'
-
$error\n$trace
βAssertionException: Expected 'true' but found 'false'
, followed by stacktrace on the next line