GitHub Actions Test Logger
🟢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.
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!
dotnet add package GitHubActionsTestLogger
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
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.
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
dotnet test --logger "GitHubActions;annotations.titleFormat=$test;annotations.messageFormat=$error"
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
$error— replaced with the error message
$trace— replaced with the stack trace
$framework— replaced with the target framework
[UI Tests] MyTests.Test1
Specifies the format of the annotation message used when reporting test failures.
Supports the same replacement tokens as
AssertionException: Expected 'true' but found 'false'
AssertionException: Expected 'true' but found 'false', followed by stacktrace on the next line