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 Oct 15, 2025
commit 05fc4e5f91bacd7e5edf47855be23b3985238993
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;

namespace GitHubActionsTestLogger.Tests.Fakes;
namespace GitHubActionsTestLogger.Tests.VsTest;

#pragma warning disable CS0067

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;

namespace GitHubActionsTestLogger.Tests.Utils;
namespace GitHubActionsTestLogger.Tests.VsTest;

internal class VsTestResultBuilder
{
Expand Down
3 changes: 1 addition & 2 deletions GitHubActionsTestLogger.Tests/VsTestAnnotationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using FluentAssertions;
using GitHubActionsTestLogger.GitHub;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.Fakes;
using GitHubActionsTestLogger.Tests.Utils;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;
using Xunit.Abstractions;
using TestOutcome = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome;
Expand Down
14 changes: 7 additions & 7 deletions GitHubActionsTestLogger.Tests/VsTestInitializationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using FluentAssertions;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.Fakes;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;

namespace GitHubActionsTestLogger.Tests;
Expand Down Expand Up @@ -48,11 +48,11 @@ public void I_can_use_the_logger_with_a_custom_configuration()
var events = new FakeTestLoggerEvents();
var parameters = new Dictionary<string, string?>
{
["annotations.titleFormat"] = "TitleFormat",
["annotations.messageFormat"] = "MessageFormat",
["summary.includePassedTests"] = "true",
["summary.includeSkippedTests"] = "true",
["summary.includeNotFoundTests"] = "true",
["annotations-title-format"] = "TitleFormat",
["annotations-message-format"] = "MessageFormat",
["summary-allow-empty"] = "true",
["summary-include-passed-tests"] = "true",
["summary-include-skipped-tests"] = "true",
};

// Act
Expand All @@ -62,8 +62,8 @@ public void I_can_use_the_logger_with_a_custom_configuration()
logger.Context.Should().NotBeNull();
logger.Context?.Options.AnnotationTitleFormat.Should().Be("TitleFormat");
logger.Context?.Options.AnnotationMessageFormat.Should().Be("MessageFormat");
logger.Context?.Options.SummaryAllowEmpty.Should().BeTrue();
logger.Context?.Options.SummaryIncludePassedTests.Should().BeTrue();
logger.Context?.Options.SummaryIncludeSkippedTests.Should().BeTrue();
logger.Context?.Options.SummaryIncludeNotFoundTests.Should().BeTrue();
}
}
13 changes: 6 additions & 7 deletions GitHubActionsTestLogger.Tests/VsTestSummarySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using FluentAssertions;
using GitHubActionsTestLogger.GitHub;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.Fakes;
using GitHubActionsTestLogger.Tests.Utils;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;
using Xunit.Abstractions;
using TestOutcome = Microsoft.VisualStudio.TestPlatform.ObjectModel.TestOutcome;
Expand All @@ -25,7 +24,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_test_sui
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludeNotFoundTests = true }
new TestReportingOptions { SummaryAllowEmpty = true }
)
);

Expand Down Expand Up @@ -315,7 +314,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_the_
}

[Fact]
public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_suites()
public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_runs()
{
// Arrange
using var summaryWriter = new StringWriter();
Expand All @@ -327,7 +326,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_s
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludeNotFoundTests = true }
new TestReportingOptions { SummaryAllowEmpty = true }
)
);

Expand All @@ -342,7 +341,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_s
}

[Fact]
public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_empty_test_suites()
public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_empty_test_runs()
{
// Arrange
using var summaryWriter = new StringWriter();
Expand All @@ -354,7 +353,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_empt
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludeNotFoundTests = false }
new TestReportingOptions { SummaryAllowEmpty = false }
)
);

Expand Down
111 changes: 25 additions & 86 deletions GitHubActionsTestLogger/MtpLoggerOptionsProvider.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GitHubActionsTestLogger.Reporting;
using Microsoft.Testing.Platform.CommandLine;
using Microsoft.Testing.Platform.Extensions;
using Microsoft.Testing.Platform.Extensions.CommandLine;
Expand All @@ -9,110 +9,49 @@ namespace GitHubActionsTestLogger;

internal class MtpLoggerOptionsProvider : MtpExtensionBase, 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 IReadOnlyCollection<CommandLineOption> GetCommandLineOptions() =>
[
new(
ReportGitHubOption,
"Reports test run information to GitHub Actions",
ArgumentArity.Zero,
isHidden: false
TestReportingOptions.CommandLineNames.AnnotationsTitleFormat,
$"Specifies the title format for GitHub Annotations. See documentation for available replacement tokens. Default is '{TestReportingOptions.Default.AnnotationTitleFormat}'.",
ArgumentArity.ExactlyOne,
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
TestReportingOptions.CommandLineNames.AnnotationsMessageFormat,
$"Specifies the message format for GitHub Annotations. See documentation for available replacement tokens. Default is '{TestReportingOptions.Default.AnnotationMessageFormat}'.",
ArgumentArity.ExactlyOne,
false
),
new(
ReportGitHubTitleOption,
"Defines the annotation title format used for reporting test failures",
ArgumentArity.ExactlyOne,
isHidden: false
TestReportingOptions.CommandLineNames.SummaryIncludePassedTests,
$"Whether to include passed tests (in addition to failed tests) in the GitHub Actions summary. Default is '{TestReportingOptions.Default.SummaryIncludePassedTests}'.",
ArgumentArity.ZeroOrOne,
false
),
new(
ReportGitHubMessageOption,
"Defines the annotation message format used for reporting test failures",
ArgumentArity.ExactlyOne,
isHidden: false
TestReportingOptions.CommandLineNames.SummaryIncludeSkippedTests,
$"Whether to include skipped tests (in addition to failed tests) in the GitHub Actions summary. Default is '{TestReportingOptions.Default.SummaryIncludeSkippedTests}'.",
ArgumentArity.ZeroOrOne,
false
),
new(
TestReportingOptions.CommandLineNames.SummaryAllowEmpty,
$"Whether to produce a summary entry for test runs where no tests were executed. Default is '{TestReportingOptions.Default.SummaryAllowEmpty}'.",
ArgumentArity.ZeroOrOne,
false
),
];

// 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;
}
) => 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 (var 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;
}
) => ValidationResult.ValidTask;
}
4 changes: 1 addition & 3 deletions GitHubActionsTestLogger/Reporting/TestReportingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ public void HandleTestRunEnd(TestRunEndInfo info)
_stopwatch.Stop();

// Don't render empty summary for projects with no tests
if (!Options.SummaryIncludeNotFoundTests && info.OverallOutcome == TestOutcome.None)
{
if (!Options.SummaryAllowEmpty && info.OverallOutcome == TestOutcome.None)
return;
}

var filteredTestResults = info
.TestResults.Where(r =>
Expand Down
92 changes: 57 additions & 35 deletions GitHubActionsTestLogger/Reporting/TestReportingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,83 @@ internal partial class TestReportingOptions

public string AnnotationMessageFormat { get; init; } = "@error";

public bool SummaryAllowEmpty { get; init; }

public bool SummaryIncludePassedTests { get; init; } = true;

public bool SummaryIncludeSkippedTests { get; init; } = true;

public bool SummaryIncludeNotFoundTests { get; init; }
}

internal partial class TestReportingOptions
{
public static TestReportingOptions Default { get; } = new();
}

internal partial class TestReportingOptions
{
public static class CommandLineNames
{
public const string MtpPrefix = "github-";
public const string AnnotationsTitleFormat = "annotations-title-format";
public const string AnnotationsMessageFormat = "annotations-message-format";
public const string SummaryAllowEmpty = "summary-allow-empty";
public const string SummaryIncludePassedTests = "summary-include-passed-tests";
public const string SummaryIncludeSkippedTests = "summary-include-skipped-tests";
}

public static TestReportingOptions Resolve(IReadOnlyDictionary<string, string?> parameters) =>
new()
{
AnnotationTitleFormat =
parameters.GetValueOrDefault("annotations.titleFormat")
parameters.GetValueOrDefault(CommandLineNames.AnnotationsTitleFormat)
?? Default.AnnotationTitleFormat,
AnnotationMessageFormat =
parameters.GetValueOrDefault("annotations.messageFormat")
parameters.GetValueOrDefault(CommandLineNames.AnnotationsMessageFormat)
?? Default.AnnotationMessageFormat,
SummaryAllowEmpty =
parameters.GetValueOrDefault(CommandLineNames.SummaryAllowEmpty)?.Pipe(bool.Parse)
?? Default.SummaryAllowEmpty,
SummaryIncludePassedTests =
parameters.GetValueOrDefault("summary.includePassedTests")?.Pipe(bool.Parse)
?? Default.SummaryIncludePassedTests,
parameters
.GetValueOrDefault(CommandLineNames.SummaryIncludePassedTests)
?.Pipe(bool.Parse) ?? Default.SummaryIncludePassedTests,
SummaryIncludeSkippedTests =
parameters.GetValueOrDefault("summary.includeSkippedTests")?.Pipe(bool.Parse)
?? Default.SummaryIncludeSkippedTests,
SummaryIncludeNotFoundTests =
parameters.GetValueOrDefault("summary.includeNotFoundTests")?.Pipe(bool.Parse)
?? Default.SummaryIncludeNotFoundTests,
parameters
.GetValueOrDefault(CommandLineNames.SummaryIncludeSkippedTests)
?.Pipe(bool.Parse) ?? Default.SummaryIncludeSkippedTests,
};

public static TestReportingOptions Resolve(ICommandLineOptions commandLineOptions)
{
var annotationTitleFormat =
commandLineOptions.TryGetOptionArgument(
MtpLoggerOptionsProvider.ReportGitHubTitleOption
) ?? Default.AnnotationTitleFormat;

var annotationMessageFormat =
commandLineOptions.TryGetOptionArgument(
MtpLoggerOptionsProvider.ReportGitHubMessageOption
) ?? Default.AnnotationMessageFormat;

// TODO: wire these
var summaryIncludePassedTests = Default.SummaryIncludePassedTests;
var summaryIncludeSkippedTests = Default.SummaryIncludeSkippedTests;
var summaryIncludeNotFoundTests = Default.SummaryIncludeNotFoundTests;

return new TestReportingOptions
public static TestReportingOptions Resolve(ICommandLineOptions commandLineOptions) =>
new()
{
AnnotationTitleFormat = annotationTitleFormat,
AnnotationMessageFormat = annotationMessageFormat,
SummaryIncludePassedTests = summaryIncludePassedTests,
SummaryIncludeSkippedTests = summaryIncludeSkippedTests,
SummaryIncludeNotFoundTests = summaryIncludeNotFoundTests,
AnnotationTitleFormat =
commandLineOptions.GetOptionArgumentOrDefault(
CommandLineNames.MtpPrefix + CommandLineNames.AnnotationsTitleFormat
) ?? Default.AnnotationTitleFormat,
AnnotationMessageFormat =
commandLineOptions.GetOptionArgumentOrDefault(
CommandLineNames.MtpPrefix + CommandLineNames.AnnotationsMessageFormat
) ?? Default.AnnotationMessageFormat,
SummaryAllowEmpty =
commandLineOptions
.GetOptionArgumentOrDefault(
CommandLineNames.MtpPrefix + CommandLineNames.SummaryAllowEmpty,
"true"
)
?.Pipe(bool.Parse) ?? Default.SummaryAllowEmpty,
SummaryIncludePassedTests =
commandLineOptions
.GetOptionArgumentOrDefault(
CommandLineNames.MtpPrefix + CommandLineNames.SummaryIncludePassedTests,
"true"
)
?.Pipe(bool.Parse) ?? Default.SummaryIncludePassedTests,
SummaryIncludeSkippedTests =
commandLineOptions
.GetOptionArgumentOrDefault(
CommandLineNames.MtpPrefix + CommandLineNames.SummaryIncludeSkippedTests,
"true"
)
?.Pipe(bool.Parse) ?? Default.SummaryIncludeSkippedTests,
};
}
}
Loading
Loading