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 17, 2025
commit d680c002645800481ff01f38314e3124127b441b
109 changes: 42 additions & 67 deletions GitHubActionsTestLogger.Tests/VsTestAnnotationSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using GitHubActionsTestLogger.GitHub;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -20,13 +19,7 @@ public void I_can_use_the_logger_to_produce_annotations_for_failed_tests()
var events = new FakeTestLoggerEvents();
var logger = new VsTestLogger();

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestReportingOptions.Default
)
);
logger.Initialize(events, [], commandWriter, TextWriter.Null);

// Act
events.SimulateTestRun(
Expand Down Expand Up @@ -70,13 +63,7 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_source_info
var events = new FakeTestLoggerEvents();
var logger = new VsTestLogger();

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestReportingOptions.Default
)
);
logger.Initialize(events, [], commandWriter, TextWriter.Null);

// Act
events.SimulateTestRun(
Expand Down Expand Up @@ -126,13 +113,7 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_source_info
var events = new FakeTestLoggerEvents();
var logger = new VsTestLogger();

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
TestReportingOptions.Default
)
);
logger.Initialize(events, [], commandWriter, TextWriter.Null);

// Act
events.SimulateTestRun(
Expand Down Expand Up @@ -185,14 +166,13 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_test_na

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions
{
AnnotationTitleFormat = "<@test>",
AnnotationMessageFormat = "[@test]",
}
)
new Dictionary<string, string?>
{
["annotations-title"] = "<@test>",
["annotations-message"] = "[@test]",
},
commandWriter,
TextWriter.Null
);

// Act
Expand Down Expand Up @@ -220,14 +200,13 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_test_traits

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions
{
AnnotationTitleFormat = "<@traits.Category -> @test>",
AnnotationMessageFormat = "[@traits.Category -> @test]",
}
)
new Dictionary<string, string?>
{
["annotations-title"] = "<@traits.Category -> @test>",
["annotations-message"] = "[@traits.Category -> @test]",
},
commandWriter,
TextWriter.Null
);

// Act
Expand Down Expand Up @@ -260,14 +239,13 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_error_m

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions
{
AnnotationTitleFormat = "<@test: @error>",
AnnotationMessageFormat = "[@test: @error]",
}
)
new Dictionary<string, string?>
{
["annotations-title"] = "<@test: @error>",
["annotations-message"] = "[@test: @error]",
},
commandWriter,
TextWriter.Null
);

// Act
Expand Down Expand Up @@ -299,14 +277,13 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_error_s

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions
{
AnnotationTitleFormat = "<@test: @trace>",
AnnotationMessageFormat = "[@test: @trace]",
}
)
new Dictionary<string, string?>
{
["annotations-title"] = "<@test: @trace>",
["annotations-message"] = "[@test: @trace]",
},
commandWriter,
TextWriter.Null
);

// Act
Expand Down Expand Up @@ -338,14 +315,13 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_the_target_

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions
{
AnnotationTitleFormat = "<@test (@framework)>",
AnnotationMessageFormat = "[@test (@framework)]",
}
)
new Dictionary<string, string?>
{
["annotations-title"] = "<@test (@framework)>",
["annotations-message"] = "[@test (@framework)]",
},
commandWriter,
TextWriter.Null
);

// Act
Expand Down Expand Up @@ -379,10 +355,9 @@ public void I_can_use_the_logger_to_produce_annotations_that_include_line_breaks

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(commandWriter, TextWriter.Null),
new TestReportingOptions { AnnotationMessageFormat = "foo\\nbar" }
)
new Dictionary<string, string?> { ["annotations-message"] = "foo\\nbar" },
commandWriter,
TextWriter.Null
);

// Act
Expand Down
44 changes: 6 additions & 38 deletions GitHubActionsTestLogger.Tests/VsTestInitializationSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;

Expand All @@ -16,12 +14,11 @@ public void I_can_use_the_logger_with_the_default_configuration()
var logger = new VsTestLogger();
var events = new FakeTestLoggerEvents();

// Act
// Act & assert
logger.Initialize(events, Directory.GetCurrentDirectory());

// Assert
logger.Context.Should().NotBeNull();
logger.Context?.Options.Should().BeEquivalentTo(TestReportingOptions.Default);
// Can't perform a more meaningful assertion here without
// accessing internal members of the logger.
}

[Fact]
Expand All @@ -31,39 +28,10 @@ public void I_can_use_the_logger_with_an_empty_configuration()
var logger = new VsTestLogger();
var events = new FakeTestLoggerEvents();

// Act
// Act & assert
logger.Initialize(events, new Dictionary<string, string?>());

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

[Fact]
public void I_can_use_the_logger_with_a_custom_configuration()
{
// Arrange
var logger = new VsTestLogger();

var events = new FakeTestLoggerEvents();
var parameters = new Dictionary<string, string?>
{
["annotations-title"] = "TitleFormat",
["annotations-message"] = "MessageFormat",
["summary-allow-empty"] = "true",
["summary-include-passed"] = "true",
["summary-include-skipped"] = "true",
};

// Act
logger.Initialize(events, parameters);

// Assert
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();
// Can't perform a more meaningful assertion here without
// accessing internal members of the logger.
}
}
60 changes: 23 additions & 37 deletions GitHubActionsTestLogger.Tests/VsTestSummarySpecs.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.IO;
using FluentAssertions;
using GitHubActionsTestLogger.GitHub;
using GitHubActionsTestLogger.Reporting;
using GitHubActionsTestLogger.Tests.VsTest;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -22,10 +21,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_test_sui

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryAllowEmpty = true }
)
new Dictionary<string, string?> { ["summary-allow-empty"] = "true" },
TextWriter.Null,
summaryWriter
);

// Act
Expand All @@ -48,13 +46,7 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_
var events = new FakeTestLoggerEvents();
var logger = new VsTestLogger();

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
TestReportingOptions.Default
)
);
logger.Initialize(events, [], TextWriter.Null, summaryWriter);

// Act
events.SimulateTestRun(
Expand Down Expand Up @@ -112,10 +104,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludePassedTests = true }
)
new Dictionary<string, string?> { ["summary-include-passed"] = "true" },
TextWriter.Null,
summaryWriter
);

// Act
Expand Down Expand Up @@ -165,10 +156,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_the_

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludePassedTests = false }
)
new Dictionary<string, string?> { ["summary-include-passed"] = "false" },
TextWriter.Null,
summaryWriter
);

// Act
Expand Down Expand Up @@ -218,10 +208,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_the_list_of_

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludeSkippedTests = true }
)
new Dictionary<string, string?> { ["summary-include-skipped"] = "true" },
TextWriter.Null,
summaryWriter
);

// Act
Expand Down Expand Up @@ -271,10 +260,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_the_

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryIncludeSkippedTests = false }
)
new Dictionary<string, string?> { ["summary-include-skipped"] = "false" },
TextWriter.Null,
summaryWriter
);

// Act
Expand Down Expand Up @@ -324,10 +312,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_includes_empty_test_r

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryAllowEmpty = true }
)
new Dictionary<string, string?> { ["summary-allow-empty"] = "true" },
TextWriter.Null,
summaryWriter
);

// Act
Expand All @@ -351,10 +338,9 @@ public void I_can_use_the_logger_to_produce_a_summary_that_does_not_include_empt

logger.Initialize(
events,
new TestReportingContext(
new GitHubWorkflow(TextWriter.Null, summaryWriter),
new TestReportingOptions { SummaryAllowEmpty = false }
)
new Dictionary<string, string?> { ["summary-allow-empty"] = "false" },
TextWriter.Null,
summaryWriter
);

// Act
Expand Down
24 changes: 9 additions & 15 deletions GitHubActionsTestLogger/GitHub/GitHubWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,13 @@ public void CreateSummary(string content)

internal partial class GitHubWorkflow
{
public static GitHubWorkflow Default { get; } =
new(
// Commands are written to the standard output
Console.Out,
// Summary is written to the file specified by an environment variable.
// We may need to write to the summary file from multiple test suites in parallel,
// so we should use a stream that delays acquiring the file lock until the very last moment,
// and employs retry logic to handle potential race conditions.
GitHubEnvironment
.SummaryFilePath?.Pipe(f => new ContentionTolerantWriteFileStream(
f,
FileMode.Append
))
.Pipe(s => new StreamWriter(s)) ?? TextWriter.Null
);
public static TextWriter DefaultCommandWriter => Console.Out;

public static TextWriter DefaultSummaryWriter => // Summary is written to the file specified by an environment variable.
// We may need to write to the summary file from multiple test suites in parallel,
// so we should use a stream that delays acquiring the file lock until the very last moment,
// and employs retry logic to handle potential race conditions.
GitHubEnvironment
.SummaryFilePath?.Pipe(f => new ContentionTolerantWriteFileStream(f, FileMode.Append))
.Pipe(s => new StreamWriter(s)) ?? TextWriter.Null;
}
Loading
Loading