Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix timing in simple log #5143

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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