Skip to content

Commit

Permalink
Fix incorrect fallback for the "include not found tests" option (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored May 29, 2024
1 parent 0a45746 commit 11b6687
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
21 changes: 19 additions & 2 deletions GitHubActionsTestLogger.Tests/InitializationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,22 @@ public void I_can_use_the_logger_with_the_default_configuration()

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

[Fact]
public void I_can_use_the_logger_with_an_empty_configuration()
{
// Arrange
var logger = new TestLogger();
var events = new FakeTestLoggerEvents();

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

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

[Fact]
Expand All @@ -35,7 +50,8 @@ public void I_can_use_the_logger_with_a_custom_configuration()
["annotations.titleFormat"] = "TitleFormat",
["annotations.messageFormat"] = "MessageFormat",
["summary.includePassedTests"] = "true",
["summary.includeSkippedTests"] = "true"
["summary.includeSkippedTests"] = "true",
["summary.includeNotFoundTests"] = "true"
};

// Act
Expand All @@ -47,5 +63,6 @@ public void I_can_use_the_logger_with_a_custom_configuration()
logger.Context?.Options.AnnotationMessageFormat.Should().Be("MessageFormat");
logger.Context?.Options.SummaryIncludePassedTests.Should().BeTrue();
logger.Context?.Options.SummaryIncludeSkippedTests.Should().BeTrue();
logger.Context?.Options.SummaryIncludeNotFoundTests.Should().BeTrue();
}
}
2 changes: 1 addition & 1 deletion GitHubActionsTestLogger/TestLoggerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public static TestLoggerOptions Resolve(IReadOnlyDictionary<string, string?> par
?? Default.SummaryIncludeSkippedTests,
SummaryIncludeNotFoundTests =
parameters.GetValueOrDefault("summary.includeNotFoundTests")?.Pipe(bool.Parse)
?? Default.SummaryIncludeSkippedTests
?? Default.SummaryIncludeNotFoundTests
};
}
26 changes: 8 additions & 18 deletions GitHubActionsTestLogger/TestRunStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,13 @@ internal record TestRunStatistics(
TimeSpan OverallDuration
)
{
public TestOutcome OverallOutcome
{
get
public TestOutcome OverallOutcome { get; } =
true switch
{
if (FailedTestCount > 0)
return TestOutcome.Failed;

if (PassedTestCount > 0)
return TestOutcome.Passed;

if (SkippedTestCount > 0)
return TestOutcome.Skipped;

if (TotalTestCount == 0)
return TestOutcome.NotFound;

return TestOutcome.None;
}
}
_ when FailedTestCount > 0 => TestOutcome.Failed,
_ when PassedTestCount > 0 => TestOutcome.Passed,
_ when SkippedTestCount > 0 => TestOutcome.Skipped,
_ when TotalTestCount == 0 => TestOutcome.NotFound,
_ => TestOutcome.None
};
}

0 comments on commit 11b6687

Please sign in to comment.