✅ Project status: active[?]
Custom logger for dotnet test
that reports test results in a structured format that GitHub Actions understands.
When using this logger, failed tests are listed in workflow annotations and highlighted in code diffs.
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! 🇺🇦
📦 NuGet: dotnet add package GitHubActionsTestLogger
To use GitHub Actions Test Logger, follow these steps:
- Install GitHubActionsTestLogger package in your test project
- Install Microsoft.NET.Test.Sdk package in your test project (or update to latest)
- 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/[email protected]
- name: Install .NET
uses: actions/[email protected]
with:
dotnet-version: 5.0.x
- name: Build & test
run: dotnet test --configuration Release --logger GitHubActions
⚠️ Ensure that your test project references Microsoft.NET.Test.Sdk version 16.8.0 or higher. Older versions of this package may not work properly with custom test loggers.
⚠️ 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 a few 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;option1=foo;option2=bar"
Specifies the format used when logging test results to the console.
The following replacement tokens are available:
$test
-- replaced with the display name of the test$outcome
-- replaced with the error message (in case of an exception) or the outcome of the test$traits.TRAIT_NAME
-- replaced with the value of a trait namedTRAIT_NAME
Default: $test: $outcome
.
Examples:
$test: $outcome
->MyTests.Test1: AssertionException: Expected 'true' but found 'false'
[$traits.Category] $test: $outcome
->[UI Tests] MyTests.Test1: AssertionException: Expected 'true' but found 'false'
Specifies whether to additionally report warnings for tests that have neither failed nor succeeded (i.e. skipped or inconclusive). If disabled, only failed tests will be reported.
Can be set to either true
or false
.
Default: true
.