Skip to content

Commit 11b6687

Browse files
authored
Fix incorrect fallback for the "include not found tests" option (#27)
1 parent 0a45746 commit 11b6687

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

GitHubActionsTestLogger.Tests/InitializationSpecs.cs

+19-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ public void I_can_use_the_logger_with_the_default_configuration()
2020

2121
// Assert
2222
logger.Context.Should().NotBeNull();
23-
logger.Context?.Options.Should().Be(TestLoggerOptions.Default);
23+
logger.Context?.Options.Should().BeEquivalentTo(TestLoggerOptions.Default);
24+
}
25+
26+
[Fact]
27+
public void I_can_use_the_logger_with_an_empty_configuration()
28+
{
29+
// Arrange
30+
var logger = new TestLogger();
31+
var events = new FakeTestLoggerEvents();
32+
33+
// Act
34+
logger.Initialize(events, new Dictionary<string, string?>());
35+
36+
// Assert
37+
logger.Context.Should().NotBeNull();
38+
logger.Context?.Options.Should().BeEquivalentTo(TestLoggerOptions.Default);
2439
}
2540

2641
[Fact]
@@ -35,7 +50,8 @@ public void I_can_use_the_logger_with_a_custom_configuration()
3550
["annotations.titleFormat"] = "TitleFormat",
3651
["annotations.messageFormat"] = "MessageFormat",
3752
["summary.includePassedTests"] = "true",
38-
["summary.includeSkippedTests"] = "true"
53+
["summary.includeSkippedTests"] = "true",
54+
["summary.includeNotFoundTests"] = "true"
3955
};
4056

4157
// Act
@@ -47,5 +63,6 @@ public void I_can_use_the_logger_with_a_custom_configuration()
4763
logger.Context?.Options.AnnotationMessageFormat.Should().Be("MessageFormat");
4864
logger.Context?.Options.SummaryIncludePassedTests.Should().BeTrue();
4965
logger.Context?.Options.SummaryIncludeSkippedTests.Should().BeTrue();
66+
logger.Context?.Options.SummaryIncludeNotFoundTests.Should().BeTrue();
5067
}
5168
}

GitHubActionsTestLogger/TestLoggerOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public static TestLoggerOptions Resolve(IReadOnlyDictionary<string, string?> par
3737
?? Default.SummaryIncludeSkippedTests,
3838
SummaryIncludeNotFoundTests =
3939
parameters.GetValueOrDefault("summary.includeNotFoundTests")?.Pipe(bool.Parse)
40-
?? Default.SummaryIncludeSkippedTests
40+
?? Default.SummaryIncludeNotFoundTests
4141
};
4242
}

GitHubActionsTestLogger/TestRunStatistics.cs

+8-18
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@ internal record TestRunStatistics(
1111
TimeSpan OverallDuration
1212
)
1313
{
14-
public TestOutcome OverallOutcome
15-
{
16-
get
14+
public TestOutcome OverallOutcome { get; } =
15+
true switch
1716
{
18-
if (FailedTestCount > 0)
19-
return TestOutcome.Failed;
20-
21-
if (PassedTestCount > 0)
22-
return TestOutcome.Passed;
23-
24-
if (SkippedTestCount > 0)
25-
return TestOutcome.Skipped;
26-
27-
if (TotalTestCount == 0)
28-
return TestOutcome.NotFound;
29-
30-
return TestOutcome.None;
31-
}
32-
}
17+
_ when FailedTestCount > 0 => TestOutcome.Failed,
18+
_ when PassedTestCount > 0 => TestOutcome.Passed,
19+
_ when SkippedTestCount > 0 => TestOutcome.Skipped,
20+
_ when TotalTestCount == 0 => TestOutcome.NotFound,
21+
_ => TestOutcome.None
22+
};
3323
}

0 commit comments

Comments
 (0)