Skip to content

Commit 205ed17

Browse files
authored
Fix timing in simple log (#5143)
1 parent 525565d commit 205ed17

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/vstest.console/Internal/ConsoleLogger.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,20 @@ public MinimalTestResult(TestResult testResult)
909909
Outcome = testResult.Outcome;
910910
StartTime = testResult.StartTime;
911911
EndTime = testResult.EndTime;
912+
913+
// When the test framework (e.g. xUnit 2.x.x) does not report start or end time
914+
// we assign it to UTC now when constructing the test result. But that does not
915+
// work for our logger, because we take the earliest StartTime and oldest EndTime
916+
// to calculate the duration and this makes the first test to be "missing" from the
917+
// duration.
918+
//
919+
// Instead we subtract the duration to get a more accurate result. We also
920+
// don't compare the times for equality because the times in the TestResult are assigned
921+
// on two different lines so they don't have to be the same.
922+
if (EndTime - StartTime < testResult.Duration)
923+
{
924+
StartTime = EndTime - testResult.Duration;
925+
}
912926
}
913927

914928
public TestCase TestCase { get; }

0 commit comments

Comments
 (0)