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
Next Next commit
Migrate from vstest to Microsoft.Testing.Platform (#43)
Co-authored-by: Martin Costello <[email protected]>
Co-authored-by: Oleksii Holub <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2025
commit 38febc98acf6574be32aef3e1cc99cb210b1c5cb
36 changes: 18 additions & 18 deletions GitHubActionsTestLogger.Tests/AnnotationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public void I_can_use_the_logger_to_produce_annotations_for_failed_tests()
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand Down Expand Up @@ -54,9 +54,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_source_info
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand Down Expand Up @@ -104,9 +104,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_source_info
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand Down Expand Up @@ -155,9 +155,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_test_na
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions
new TestReporterOptions
{
AnnotationTitleFormat = "<@test>",
AnnotationMessageFormat = "[@test]",
Expand All @@ -184,9 +184,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_test_traits
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions
new TestReporterOptions
{
AnnotationTitleFormat = "<@traits.Category -> @test>",
AnnotationMessageFormat = "[@traits.Category -> @test]",
Expand Down Expand Up @@ -218,9 +218,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_error_m
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions
new TestReporterOptions
{
AnnotationTitleFormat = "<@test: @error>",
AnnotationMessageFormat = "[@test: @error]",
Expand Down Expand Up @@ -251,9 +251,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_error_s
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions
new TestReporterOptions
{
AnnotationTitleFormat = "<@test: @trace>",
AnnotationMessageFormat = "[@test: @trace]",
Expand Down Expand Up @@ -284,9 +284,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_target_
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions
new TestReporterOptions
{
AnnotationTitleFormat = "<@test (@framework)>",
AnnotationMessageFormat = "[@test (@framework)]",
Expand Down Expand Up @@ -319,9 +319,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_line_breaks
// Arrange
using var commandWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestLoggerOptions { AnnotationMessageFormat = "foo\\nbar" }
new TestReporterOptions { AnnotationMessageFormat = "foo\\nbar" }
);

// Act
Expand Down
4 changes: 2 additions & 2 deletions GitHubActionsTestLogger.Tests/InitializationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void I_can_use_the_logger_with_the_default_configuration()

// Assert
logger.Context.Should().NotBeNull();
logger.Context?.Options.Should().BeEquivalentTo(TestLoggerOptions.Default);
logger.Context?.Options.Should().BeEquivalentTo(TestReporterOptions.Default);
}

[Fact]
Expand All @@ -35,7 +35,7 @@ public void I_can_use_the_logger_with_an_empty_configuration()

// Assert
logger.Context.Should().NotBeNull();
logger.Context?.Options.Should().BeEquivalentTo(TestLoggerOptions.Default);
logger.Context?.Options.Should().BeEquivalentTo(TestReporterOptions.Default);
}

[Fact]
Expand Down
24 changes: 12 additions & 12 deletions GitHubActionsTestLogger.Tests/SummarySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_test_sui
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand All @@ -38,9 +38,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestLoggerOptions { SummaryIncludePassedTests = true }
new TestReporterOptions { SummaryIncludePassedTests = true }
);

// Act
Expand Down Expand Up @@ -85,9 +85,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand Down Expand Up @@ -144,9 +144,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestLoggerOptions { SummaryIncludeSkippedTests = true }
new TestReporterOptions { SummaryIncludeSkippedTests = true }
);

// Act
Expand Down Expand Up @@ -191,9 +191,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_s
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
TestLoggerOptions.Default
TestReporterOptions.Default
);

// Act
Expand All @@ -212,9 +212,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_empt
// Arrange
using var summaryWriter = new StringWriter();

var context = new TestLoggerContext(
var context = new TestReporterContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestLoggerOptions { SummaryIncludeNotFoundTests = false }
new TestReporterOptions { SummaryIncludeNotFoundTests = false }
);

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace GitHubActionsTestLogger.Tests.Utils.Extensions;
internal static class TestLoggerContextExtensions
{
public static void SimulateTestRun(
this TestLoggerContext context,
this TestReporterContext context,
string testSuiteFilePath,
string targetFrameworkName,
params IReadOnlyList<TestResult> testResults
Expand Down Expand Up @@ -65,13 +65,13 @@ params IReadOnlyList<TestResult> testResults
}

public static void SimulateTestRun(
this TestLoggerContext context,
this TestReporterContext context,
string testSuiteName,
params IReadOnlyList<TestResult> testResults
) => context.SimulateTestRun(testSuiteName, "FakeTargetFramework", testResults);

public static void SimulateTestRun(
this TestLoggerContext context,
this TestReporterContext context,
params IReadOnlyList<TestResult> testResults
) => context.SimulateTestRun("FakeTests.dll", testResults);
}
89 changes: 89 additions & 0 deletions GitHubActionsTestLogger/CliOptionsProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Microsoft.Testing.Platform.CommandLine;
using Microsoft.Testing.Platform.Extensions;
using Microsoft.Testing.Platform.Extensions.CommandLine;

namespace GitHubActionsTestLogger;

internal sealed class CliOptionsProvider(GitHubTestReporterExtension extension) : ICommandLineOptionsProvider
{
public const string ReportGitHubOption = "report-github";
public const string ReportGitHubSummaryOption = "report-github-summary";
public const string ReportGitHubTitleOption = "report-github-title";
public const string ReportGitHubMessageOption = "report-github-message";

public static class ReportGitHubSummaryArguments
{
public const string IncludePassedTests = "includePassedTests";
public const string IncludeSkippedTests = "includeSkippedTests";
public const string IncludeNotFoundTests = "includeNotFoundTests";
}

public string Uid => extension.Uid;
public string Version => extension.Version;
public string DisplayName => extension.DisplayName;
public string Description => extension.Description;

public IReadOnlyCollection<CommandLineOption> GetCommandLineOptions() =>
[
new(ReportGitHubOption, "Reports test run information to GitHub Actions", ArgumentArity.Zero, isHidden: false),
// TODO: Do you prefer multiple zero argument options or a single option with argument?
new(ReportGitHubSummaryOption, "Defines the information to include in the summary", ArgumentArity.OneOrMore, isHidden: false),
new(ReportGitHubTitleOption, "Defines the annotation title format used for reporting test failures", ArgumentArity.ExactlyOne, isHidden: false),
new(ReportGitHubMessageOption, "Defines the annotation message format used for reporting test failures", ArgumentArity.ExactlyOne, isHidden: false),
];

public Task<bool> IsEnabledAsync() => extension.IsEnabledAsync();

// This method is called once after all options are parsed and is used to validate the combination of options.
public Task<ValidationResult> ValidateCommandLineOptionsAsync(ICommandLineOptions commandLineOptions)
{
// We just want to validate that the sub options are set only if the main option is set.
if (commandLineOptions.IsOptionSet(ReportGitHubOption))
{
return ValidationResult.ValidTask;
}

if (commandLineOptions.IsOptionSet(ReportGitHubSummaryOption)
|| commandLineOptions.IsOptionSet(ReportGitHubTitleOption)
|| commandLineOptions.IsOptionSet(ReportGitHubMessageOption))
{
return ValidationResult.InvalidTask("The options 'report-github-summary', 'report-github-title', and 'report-github-message' can only be used if 'report-github' is set.");
}

return ValidationResult.ValidTask;
}

// This method is called once per option declared and is used to validate the arguments of the given option.
// The arity of the option is checked before this method is called.
public Task<ValidationResult> ValidateOptionArgumentsAsync(CommandLineOption commandOption, string[] arguments)
{
if (commandOption.Name == ReportGitHubSummaryOption)
{
if (arguments.Length > 3)
{
return ValidationResult.InvalidTask($"The option '{ReportGitHubSummaryOption}' can have at most 3 arguments.");
}

if (arguments.Distinct().Count() != arguments.Length)
{
return ValidationResult.InvalidTask($"The option '{ReportGitHubSummaryOption}' cannot have duplicate arguments.");
}

for (int i = 0; i < arguments.Length; i++)
{
if (arguments[i] != ReportGitHubSummaryArguments.IncludePassedTests
&& arguments[i] != ReportGitHubSummaryArguments.IncludeSkippedTests
&& arguments[i] != ReportGitHubSummaryArguments.IncludeNotFoundTests)
{
return ValidationResult.InvalidTask($"The option '{ReportGitHubSummaryOption}' can only have the arguments '{ReportGitHubSummaryArguments.IncludePassedTests}', '{ReportGitHubSummaryArguments.IncludeSkippedTests}', and '{ReportGitHubSummaryArguments.IncludeNotFoundTests}'.");
}
}
}

return ValidationResult.ValidTask;
}
}
7 changes: 4 additions & 3 deletions GitHubActionsTestLogger/GitHubActionsTestLogger.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net9.0</TargetFrameworks>
<IsPackable>true</IsPackable>
Expand All @@ -25,8 +26,8 @@
<None Include="../favicon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CSharpier.MsBuild" Version="1.1.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.14.1" />
<PackageReference Include="CSharpier.MsBuild" Version="0.30.6" PrivateAssets="all" />
<PackageReference Include="Microsoft.Testing.Platform" Version="1.6.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
<PackageReference Include="PolyShim" Version="1.15.0" PrivateAssets="all" />
<PackageReference
Expand Down
24 changes: 24 additions & 0 deletions GitHubActionsTestLogger/GitHubReportExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Testing.Platform.Builder;
using Microsoft.Testing.Platform.Extensions;
using Microsoft.Testing.Platform.Services;

namespace GitHubActionsTestLogger;

public static class GitHubReportExtensions
{
/// <summary>
/// Adds GitHub report support to the Testing Platform Builder.
/// </summary>
/// <param name="testApplicationBuilder">The test application builder.</param>
public static void AddGitHubReportProvider(this ITestApplicationBuilder testApplicationBuilder)
{
var extension = new GitHubTestReporterExtension();

var compositeExtension = new CompositeExtensionFactory<GitHubTestReporter>(serviceProvider =>
new GitHubTestReporter(extension, serviceProvider.GetCommandLineOptions()));
testApplicationBuilder.TestHost.AddDataConsumer(compositeExtension);
testApplicationBuilder.TestHost.AddTestSessionLifetimeHandle(compositeExtension);

testApplicationBuilder.CommandLine.AddProvider(() => new CliOptionsProvider(extension));
}
}
Loading