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
wip
  • Loading branch information
Tyrrrz committed Oct 11, 2025
commit a2b5bd6f9299bb02d7d9631f4303e4a2c93bfdb0
16 changes: 7 additions & 9 deletions GitHubActionsTestLogger/GitHubReportExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ namespace GitHubActionsTestLogger;
public static class GitHubReportExtensions
{
/// <summary>
/// Adds GitHub report support to the Testing Platform Builder.
/// Adds GitHub Actions reporting 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 extension = new TestReporterExtension();

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

testApplicationBuilder.CommandLine.AddProvider(() => new CliOptionsProvider(extension));
testApplicationBuilder.CommandLine.AddProvider(
() => new TestReporterOptionsProvider(extension)
);
}
}
56 changes: 0 additions & 56 deletions GitHubActionsTestLogger/GitHubTestReporter.cs

This file was deleted.

19 changes: 0 additions & 19 deletions GitHubActionsTestLogger/GitHubTestReporterExtension.cs

This file was deleted.

4 changes: 2 additions & 2 deletions GitHubActionsTestLogger/GitHubWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace GitHubActionsTestLogger;

// https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
public partial class GitHubWorkflow(TextWriter commandWriter, TextWriter summaryWriter)
internal partial class GitHubWorkflow(TextWriter commandWriter, TextWriter summaryWriter)
{
private void InvokeCommand(
string command,
Expand Down Expand Up @@ -78,7 +78,7 @@ public void CreateSummary(string content)
}
}

public partial class GitHubWorkflow
internal partial class GitHubWorkflow
{
public static GitHubWorkflow Default { get; } =
new(
Expand Down
9 changes: 9 additions & 0 deletions GitHubActionsTestLogger/TestDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace GitHubActionsTestLogger;

internal record TestDefinition(
string Id,
string DisplayName,
IReadOnlyDictionary<string, string> Properties
);
26 changes: 26 additions & 0 deletions GitHubActionsTestLogger/TestOutcome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.Testing.Platform.Extensions.Messages;

namespace GitHubActionsTestLogger;

internal enum TestOutcome
{
None,
Passed,
Failed,
Skipped,
}

internal static class TestOutcomeExtensions
{
public static TestOutcome ToTestOutcome(this TestNodeStateProperty stateProperty) =>
stateProperty switch
{
PassedTestNodeStateProperty => TestOutcome.Passed,
FailedTestNodeStateProperty => TestOutcome.Failed,
ErrorTestNodeStateProperty => TestOutcome.Failed,
TimeoutTestNodeStateProperty => TestOutcome.Failed,
SkippedTestNodeStateProperty => TestOutcome.Skipped,
CancelledTestNodeStateProperty => TestOutcome.Skipped,
_ => TestOutcome.None,
};
}
89 changes: 89 additions & 0 deletions GitHubActionsTestLogger/TestReporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Testing.Platform.CommandLine;
using Microsoft.Testing.Platform.Extensions.Messages;
using Microsoft.Testing.Platform.Extensions.TestHost;
using Microsoft.Testing.Platform.TestHost;

namespace GitHubActionsTestLogger;

/// <summary>
/// A Microsoft.Testing.Platform extension that reports test run information to GitHub Actions.
/// </summary>
internal class TestReporter(TestReporterExtension extension, ICommandLineOptions commandLineOptions)
:
// This is the extension point to subscribe to data messages published to the platform.
// The type should then be registered as a data consumer in the test host.
IDataConsumer,
// This is the extension point to subscribe to test session lifetime events.
// The type should then be registered as a test session lifetime handler in the test host.
ITestSessionLifetimeHandler
{
private readonly TestReporterContext _context = new(
GitHubWorkflow.Default,
TestReporterOptions.Resolve(commandLineOptions)
);

public Type[] DataTypesConsumed { get; } = [typeof(TestNodeUpdateMessage)];

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

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

public Task ConsumeAsync(
IDataProducer dataProducer,
IData value,
CancellationToken cancellationToken
)
{
if (value is not TestNodeUpdateMessage message)
throw new InvalidOperationException(
$"Unexpected data type: {value.GetType().FullName}"
);

var state = message.TestNode.Properties.SingleOrDefault<TestNodeStateProperty>();
if (state is null)
throw new InvalidOperationException("Test node state property is missing.");

_context.HandleTestResult(
new TestResult(
new TestDefinition(
message.TestNode.Uid.Value,
message.TestNode.DisplayName,
message
.TestNode.Properties.OfType<TestMetadataProperty>()
.ToDictionary(p => p.Key, p => p.Value)
),
state.ToTestOutcome(),
state switch
{
FailedTestNodeStateProperty failedState => failedState.Exception,
ErrorTestNodeStateProperty errorState => errorState.Exception,
TimeoutTestNodeStateProperty timeoutState => timeoutState.Exception,
_ => null,
}
)
);

return Task.CompletedTask;
}

public Task OnTestSessionStartingAsync(
SessionUid sessionUid,
CancellationToken cancellationToken
) => Task.CompletedTask;

public Task OnTestSessionFinishingAsync(
SessionUid sessionUid,
CancellationToken cancellationToken
)
{
_context.HandleTestRunComplete();
return Task.CompletedTask;
}
}
Loading