Skip to content

Commit

Permalink
duration fixes for #153
Browse files Browse the repository at this point in the history
  • Loading branch information
elv1s42 committed May 26, 2020
1 parent 61c01ea commit 03dbb1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestRun {
name: string;
fullName: string;
description: string;
duration: number;
testInfo: ItemInfo;
testStackTrace: string;
testMessage: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ class TestRunDtoMapper {
testRunDto.name = testRun.name;
testRunDto.categories = testRun.categories;
testRunDto.description = testRun.description;
const diffTime = testRun.testInfo.finish.valueOf() - testRun.testInfo.start.valueOf();
const diffSecs = Math.round(((diffTime / 1000) + Number.EPSILON) * 100) / 100;
testRunDto.duration = diffSecs;
if (testRun.duration !== undefined && testRun.duration !== 0) {
testRunDto.duration = testRun.duration;
} else {
const diffTime = testRun.testInfo.finish.valueOf() - testRun.testInfo.start.valueOf();
const diffSecs = Math.round(((diffTime / 1000) + Number.EPSILON) * 100) / 100;
testRunDto.duration = diffSecs;
}
testRunDto.events = eventDtos;
testRunDto.fullName = testRun.fullName;
testRunDto.output = SimpleItemInfoDtoMapper.map(testRun.output);
Expand Down
1 change: 1 addition & 0 deletions Ghpr.Core.Core/Common/TestRunDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public TestRunDto(Guid guid, string name = "", string fullName = "")
Start = default(DateTime),
Finish = default(DateTime)
};
Duration = .0;
Name = name;
FullName = fullName;
Description = "";
Expand Down

0 comments on commit 03dbb1b

Please sign in to comment.