Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
38febc9
Migrate from `vstest` to `Microsoft.Testing.Platform` (#43)
Evangelink Oct 11, 2025
3fe7b21
Format
Tyrrrz Oct 11, 2025
a2b5bd6
wip
Tyrrrz Oct 11, 2025
3cd65bd
Format
Tyrrrz Oct 11, 2025
e42c6a6
asd
Tyrrrz Oct 11, 2025
ad398b2
asd
Tyrrrz Oct 11, 2025
d1c23fa
asd
Tyrrrz Oct 11, 2025
09cb57f
asd
Tyrrrz Oct 12, 2025
4e8b5df
Retrofit support for VSTest via an abstraction layer
Tyrrrz Oct 14, 2025
0fa368d
asd
Tyrrrz Oct 14, 2025
ee603f1
asd
Tyrrrz Oct 14, 2025
0ff54ee
asd
Tyrrrz Oct 14, 2025
b0959a1
asd
Tyrrrz Oct 14, 2025
2a04ac6
asd
Tyrrrz Oct 14, 2025
b375377
asd
Tyrrrz Oct 14, 2025
c3baa5e
asd
Tyrrrz Oct 14, 2025
7e73608
asd
Tyrrrz Oct 14, 2025
1ec70f8
asd
Tyrrrz Oct 14, 2025
baa088e
asd
Tyrrrz Oct 14, 2025
e202765
asd
Tyrrrz Oct 14, 2025
05fc4e5
asd
Tyrrrz Oct 15, 2025
3896f9a
asd
Tyrrrz Oct 15, 2025
4555bd6
asd
Tyrrrz Oct 15, 2025
d34bd30
asd
Tyrrrz Oct 15, 2025
86232b4
asd
Tyrrrz Oct 17, 2025
d418098
asd
Tyrrrz Oct 17, 2025
d680c00
asd
Tyrrrz Oct 17, 2025
1084ae2
MTP demo works
Tyrrrz Oct 22, 2025
af06bef
asd
Tyrrrz Oct 25, 2025
23601ff
asd
Tyrrrz Nov 1, 2025
ed6a032
asd
Tyrrrz Nov 1, 2025
201dcae
asd
Tyrrrz Nov 3, 2025
460ef7b
Upgrade to MTP v2
Tyrrrz Nov 11, 2025
77f8f51
asd
Tyrrrz Nov 11, 2025
12e4e65
Merge
Tyrrrz Nov 11, 2025
ab562cc
asd
Tyrrrz Nov 11, 2025
c367f57
Use peer deps
Tyrrrz Nov 12, 2025
f4582b9
tests
Tyrrrz Nov 14, 2025
80ff683
Async github interactions
Tyrrrz Nov 14, 2025
65a9c48
Add MTP tests
Tyrrrz Nov 17, 2025
3c4f5d5
asd
Tyrrrz Nov 17, 2025
29a8325
asd
Tyrrrz Nov 17, 2025
b6a8c73
Migrate demo projects to MSTest
Tyrrrz Nov 17, 2025
b25749c
asd
Tyrrrz Nov 17, 2025
423a9d9
asd
Tyrrrz Nov 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
asd
  • Loading branch information
Tyrrrz committed Nov 1, 2025
commit 23601ff9ff8712f00e9e94a89d5004d9d7c93538
53 changes: 53 additions & 0 deletions GitHubActionsTestLogger.Tests/MtpAnnotationSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using GitHubActionsTestLogger.Tests.VsTest;
using Microsoft.Testing.Platform.Builder;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Xunit;

namespace GitHubActionsTestLogger.Tests;

public class MtpAnnotationSpecs
{
[Fact]
public async Task I_can_use_the_logger_to_produce_annotations_for_failed_tests()
{
// Arrange
var builder = await TestApplication.CreateBuilderAsync([]);

await using var commandWriter = new StringWriter();

builder.AddGitHubActionsReporting(commandWriter, TextWriter.Null);
var app = await builder.BuildAsync();

// Act
events.SimulateTestRun(
new VsTestResultBuilder()
.SetDisplayName("Test1")
.SetOutcome(TestOutcome.Failed)
.SetErrorMessage("ErrorMessage")
.Build(),
new VsTestResultBuilder()
.SetDisplayName("Test2")
.SetOutcome(TestOutcome.Passed)
.Build(),
new VsTestResultBuilder()
.SetDisplayName("Test3")
.SetOutcome(TestOutcome.Skipped)
.Build()
);

// Assert
var output = commandWriter.ToString().Trim();

output.Should().StartWith("::error ");
output.Should().Contain("Test1");
output.Should().Contain("ErrorMessage");

output.Should().NotContain("Test2");
output.Should().NotContain("Test3");

testOutput.WriteLine(output);
}
}
21 changes: 21 additions & 0 deletions GitHubActionsTestLogger.Tests/MtpInitializationSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Microsoft.Testing.Platform.Builder;
using Xunit;

namespace GitHubActionsTestLogger.Tests;

public class MtpInitializationSpecs
{
[Fact]
public async Task I_can_use_the_logger_with_the_default_configuration()
{
// Arrange
var builder = await TestApplication.CreateBuilderAsync([]);

// Act & assert
builder.AddGitHubActionsReporting();

// Can't perform a more meaningful assertion here without
// accessing internal members of the reporter.
}
}
94 changes: 51 additions & 43 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
<img src="favicon.png" alt="Icon" />
</p>

**GitHub Actions Test Logger** is a 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.
**GitHub Actions Test Logger** is an extension for VSTest and MTP that reports test results via GitHub Actions.
It lists failed tests in job annotations, highlights them in code diffs, and produces a detailed job summary with information about the executed test run.

## Terms of use<sup>[[?]](https://github.com/Tyrrrz/.github/blob/master/docs/why-so-political.md)</sup>

Expand All @@ -45,48 +44,35 @@ To learn more about the war and how you can help, [click here](https://tyrrrz.me

## Usage

To use **GitHub Actions Test Logger**, install it in your test project and modify your GitHub Actions workflow by adding `--logger GitHubActions` to `dotnet test`:
**GitHub Actions Test Logger** is available for both the classic **VSTest** test runner and the newer **Microsoft.Testing.Platform**.

```yaml
name: main
on: [push, pull_request]
### [Microsoft.Testing.Platform](https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-intro)

jobs:
build:
runs-on: ubuntu-latest
Simply install the package in your test project.
The provided test reporter will automatically be detected and enabled when running in a GitHub Actions environment.

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

- name: Install .NET
uses: actions/setup-dotnet@v4

- name: Build & test
run: dotnet test --configuration Release --logger GitHubActions
```
### [VSTest](https://github.com/microsoft/vstest)

By default, the logger will only report failed tests in the job summary and annotations.
If you want the summary to include detailed information about passed and skipped tests as well, update the workflow as follows:
Install the package in your test project and specify the logger when running `dotnet test`:

```yaml
name: main
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
# ...
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build & test
run: >
dotnet test
--configuration Release
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
```
- name: Install .NET
uses: actions/setup-dotnet@v4

> **Warning**:
> The new testing platform (i.e. `Microsoft.Testing.Platform`) [is not yet supported](https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/41). This is because VSTest and MTP are using different extensibility models, and this project existed before MTP existed.
> To use **GitHub Actions Test Logger**, make sure to use the classic testing experience (`vstest`) instead.
- name: Build & test
run: dotnet test --configuration Release --logger GitHubActions
```

> **Important**:
> Ensure that your test project references the latest version of **Microsoft.NET.Test.Sdk**.
Expand All @@ -95,10 +81,10 @@ jobs:
> **Important**:
> If you are using **.NET SDK v2.2 or lower**, you need to [set the `<CopyLocalLockFileAssemblies>` property to `true` in your test project](https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5#issuecomment-648431667).

### Collecting source information
#### Collecting source information

**GitHub Actions Test Logger** can leverage source information to link reported test results to the locations in the source code where the corresponding tests are defined.
By default, `dotnet test` does not collect source information, so the logger relies on stack traces to extract it manually.
By default, VSTest does not collect source information, so the logger relies on stack traces to extract it manually.
This approach only works for failed tests, and even then may not always be fully accurate.

To instruct the runner to collect source information, add the `RunConfiguration.CollectSourceInformation=true` argument to the command as shown below:
Expand Down Expand Up @@ -129,7 +115,29 @@ jobs:

### Customizing behavior

When running `dotnet test`, you can customize the logger's behavior by passing additional options:
When running `dotnet test`, you can customize the logger's behavior by passing additional options on the command line:

**Microsoft.Testing.Platform**:

```yml
jobs:
build:
runs-on: ubuntu-latest

steps:
# ...

- name: Build & test
run: >
dotnet test
--configuration Release
--
--report-github
--report-github-annotations-title=@test
--report-github-annotations-message=@error
```

**VSTest**:

```yml
jobs:
Expand All @@ -148,7 +156,7 @@ jobs:

#### Custom annotation title

Use the `annotations-title` option to specify the annotation title format used for reporting test failures.
Use the `[--report-github-]annotations-title` option to specify the annotation title format used for reporting test failures.

The following replacement tokens are available:

Expand All @@ -168,7 +176,7 @@ The following replacement tokens are available:

#### Custom annotation message

Use the `annotations-message` option to specify the annotation message format used for reporting test failures.
Use the `[--report-github-]annotations-message` option to specify the annotation message format used for reporting test failures.
Supports the same replacement tokens as [`annotations-title-format`](#custom-annotation-title).
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference in the documentation is incorrect. It refers to annotations-title-format but the actual option name is annotations-title (without the -format suffix). This inconsistency could confuse users.

Copilot uses AI. Check for mistakes.

**Default**: `@error`.
Expand All @@ -180,13 +188,13 @@ Supports the same replacement tokens as [`annotations-title-format`](#custom-ann

#### Allow empty test summaries

Use the `summary-allow-empty` option to specify whether empty test runs should be included in the summary, for example as a result of using [test filters](https://learn.microsoft.com/dotnet/core/testing/selective-unit-tests).
Use the `[--report-github-]summary-allow-empty` option to specify whether empty test runs should be included in the summary, for example as a result of using [test filters](https://learn.microsoft.com/dotnet/core/testing/selective-unit-tests).

**Default**: `false`.

#### Include passed tests in the summary

Use the `summary-include-passed` option to specify whether passed tests should be included in the summary.
Use the `[--report-github-]summary-include-passed` option to specify whether passed tests should be included in the summary.
If you want to link passed tests to their corresponding source definitions, make sure to also enable [source information collection](#collecting-source-information).

**Default**: `true`.
Expand All @@ -196,7 +204,7 @@ If you want to link passed tests to their corresponding source definitions, make

#### Include skipped tests in the summary

Use the `summary-include-skipped` option to specify whether skipped tests should be included in the summary.
Use the `[--report-github-]summary-include-skipped` option to specify whether skipped tests should be included in the summary.
If you want to link skipped tests to their corresponding source definitions, make sure to also enable [source information collection](#collecting-source-information).

**Default**: `true`.
Expand Down