Skip to content

Commit

Permalink
Fix timing in simple log (#5143)
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd authored Jul 15, 2024
1 parent 525565d commit 205ed17
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/vstest.console/Internal/ConsoleLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,20 @@ public MinimalTestResult(TestResult testResult)
Outcome = testResult.Outcome;
StartTime = testResult.StartTime;
EndTime = testResult.EndTime;

// When the test framework (e.g. xUnit 2.x.x) does not report start or end time
// we assign it to UTC now when constructing the test result. But that does not
// work for our logger, because we take the earliest StartTime and oldest EndTime
// to calculate the duration and this makes the first test to be "missing" from the
// duration.
//
// Instead we subtract the duration to get a more accurate result. We also
// don't compare the times for equality because the times in the TestResult are assigned
// on two different lines so they don't have to be the same.
if (EndTime - StartTime < testResult.Duration)
{
StartTime = EndTime - testResult.Duration;
}
}

public TestCase TestCase { get; }
Expand Down

0 comments on commit 205ed17

Please # to comment.