Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Nov 21, 2023
1 parent f8a6355 commit e6c8f11
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions GitHubActionsTestLogger/TestLoggerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,39 @@ public void HandleTestRunComplete(TestRunCompleteEventArgs args)
{
lock (_lock)
{
var testSuite =
_testRunCriteria?.Sources?.FirstOrDefault()?.Pipe(Path.GetFileNameWithoutExtension)
?? "Unknown Test Suite";

var targetFramework =
_testRunCriteria?.TryGetTargetFramework() ?? "Unknown Target Framework";

var testRunStatistics = new TestRunStatistics(
(int?)args.TestRunStatistics?[TestOutcome.Passed]
?? _testResults.Count(r => r.Outcome == TestOutcome.Passed),
(int?)args.TestRunStatistics?[TestOutcome.Failed]
?? _testResults.Count(r => r.Outcome == TestOutcome.Failed),
(int?)args.TestRunStatistics?[TestOutcome.Skipped]
?? _testResults.Count(r => r.Outcome == TestOutcome.Skipped),
(int?)args.TestRunStatistics?.ExecutedTests ?? _testResults.Count,
args.ElapsedTimeInRunningTests
);

var testResults = _testResults
.Where(
r =>
r.Outcome == TestOutcome.Failed
|| r.Outcome == TestOutcome.Passed && Options.SummaryIncludePassedTests
|| r.Outcome == TestOutcome.Skipped && Options.SummaryIncludeSkippedTests
)
.ToArray();

var template = new TestSummaryTemplate
{
TestSuite =
_testRunCriteria
?.Sources
?.FirstOrDefault()
?.Pipe(Path.GetFileNameWithoutExtension) ?? "Unknown Test Suite",

TargetFramework =
_testRunCriteria?.TryGetTargetFramework() ?? "Unknown Target Framework",

TestRunStatistics = new TestRunStatistics(
(int?)args.TestRunStatistics?[TestOutcome.Passed]
?? _testResults.Count(r => r.Outcome == TestOutcome.Passed),
(int?)args.TestRunStatistics?[TestOutcome.Failed]
?? _testResults.Count(r => r.Outcome == TestOutcome.Failed),
(int?)args.TestRunStatistics?[TestOutcome.Skipped]
?? _testResults.Count(r => r.Outcome == TestOutcome.Skipped),
(int?)args.TestRunStatistics?.ExecutedTests ?? _testResults.Count,
args.ElapsedTimeInRunningTests
),

TestResults = _testResults
.Where(
r =>
r.Outcome == TestOutcome.Failed
|| r.Outcome == TestOutcome.Passed && Options.SummaryIncludePassedTests
|| r.Outcome == TestOutcome.Skipped
&& Options.SummaryIncludeSkippedTests
)
.ToArray()
TestSuite = testSuite,
TargetFramework = targetFramework,
TestRunStatistics = testRunStatistics,
TestResults = testResults
};

_github.CreateSummary(template.Render());
Expand Down

0 comments on commit e6c8f11

Please sign in to comment.