Skip to content

Commit

Permalink
fix: safe TestRunStatistics access
Browse files Browse the repository at this point in the history
  • Loading branch information
vchirikov committed Oct 24, 2022
1 parent 2e5c410 commit 725ad04
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/dotnet/Logger/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,20 @@ async Task OnTestRunCompleteInternalAsync(TestRunCompleteEventArgs results)
try
{
await Task.WhenAll(_testResults.Values.ToArray()).ConfigureAwait(false);
if (!results.TestRunStatistics.Stats.TryGetValue(TestOutcome.Passed, out var passed))
passed = 0;
if (!results.TestRunStatistics.Stats.TryGetValue(TestOutcome.Failed, out var failed))
failed = 0;
if (!results.TestRunStatistics.Stats.TryGetValue(TestOutcome.Skipped, out var skipped))
skipped = 0;

var summary = _summaryGenerator.Generate(
name: _params.name,
suite: _testRunName,
framework: _testRunFramework,
passed: results.TestRunStatistics.Stats[TestOutcome.Passed],
failed: results.TestRunStatistics.Stats[TestOutcome.Failed],
skipped: results.TestRunStatistics.Stats[TestOutcome.Skipped],
passed,
failed,
skipped,
total: results.TestRunStatistics.ExecutedTests,
elapsed: results.ElapsedTimeInRunningTests,
testResults: _testResults.Keys
Expand Down

0 comments on commit 725ad04

Please sign in to comment.