From 03dbb1bbba01d1d6e80eea95763c1dc9e935d0a5 Mon Sep 17 00:00:00 2001 From: Evgeniy Kosjakov <42_@mail.ru> Date: Tue, 26 May 2020 19:52:56 +0300 Subject: [PATCH] duration fixes for #153 --- .../common/localFileSystem/entities/TestRun.ts | 1 + .../common/localFileSystem/mappers/TestRunDtoMapper.ts | 10 +++++++--- Ghpr.Core.Core/Common/TestRunDto.cs | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Ghpr.Controller.ts/controller/common/localFileSystem/entities/TestRun.ts b/Ghpr.Controller.ts/controller/common/localFileSystem/entities/TestRun.ts index cb40d9fa..aff28f7a 100644 --- a/Ghpr.Controller.ts/controller/common/localFileSystem/entities/TestRun.ts +++ b/Ghpr.Controller.ts/controller/common/localFileSystem/entities/TestRun.ts @@ -8,6 +8,7 @@ class TestRun { name: string; fullName: string; description: string; + duration: number; testInfo: ItemInfo; testStackTrace: string; testMessage: string; diff --git a/Ghpr.Controller.ts/controller/common/localFileSystem/mappers/TestRunDtoMapper.ts b/Ghpr.Controller.ts/controller/common/localFileSystem/mappers/TestRunDtoMapper.ts index 77dedbe3..468204b8 100644 --- a/Ghpr.Controller.ts/controller/common/localFileSystem/mappers/TestRunDtoMapper.ts +++ b/Ghpr.Controller.ts/controller/common/localFileSystem/mappers/TestRunDtoMapper.ts @@ -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); diff --git a/Ghpr.Core.Core/Common/TestRunDto.cs b/Ghpr.Core.Core/Common/TestRunDto.cs index c34ab128..a5b457ba 100644 --- a/Ghpr.Core.Core/Common/TestRunDto.cs +++ b/Ghpr.Core.Core/Common/TestRunDto.cs @@ -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 = "";