public void TestFinished(ITestRun testRun) { lock (_lock) { _actionHelper.SafeAction(() => { _currentRun.RunSummary.Total++; var finishDateTime = DateTime.Now; var currentTest = _currentTestRuns.GetTest(testRun); var finalTest = testRun.Update(currentTest); var testGuid = finalTest.TestInfo.Guid.ToString(); var testPath = Path.Combine(TestsPath, testGuid); var fileName = finishDateTime.GetTestName(); _currentRun.RunSummary = _currentRun.RunSummary.Update(finalTest); finalTest.TestInfo.FileName = fileName; finalTest.RunGuid = _currentRunGuid; finalTest.TestInfo.Start = finalTest.TestInfo.Start.Equals(default(DateTime)) ? finishDateTime : finalTest.TestInfo.Start; finalTest.TestInfo.Finish = finalTest.TestInfo.Finish.Equals(default(DateTime)) ? finishDateTime : finalTest.TestInfo.Finish; finalTest.TestDuration = finalTest.TestDuration.Equals(0.0) ? (finalTest.TestInfo.Finish - finalTest.TestInfo.Start).TotalSeconds : finalTest.TestDuration; finalTest .TakeScreenshot(testPath, TakeScreenshotAfterFail) .Save(testPath, fileName); _currentTestRuns.Remove(currentTest); _currentRun.TestRunFiles.Add($"{testGuid}\\{fileName}"); TestRunsHelper.SaveCurrentTestInfo(testPath, finalTest.TestInfo); if (RealTimeGeneration) { GenerateReport(DateTime.Now); } }); } }
public void TestFinished(ITestRun testRun) { _action.Safe(() => { _currentRun.RunSummary.Total++; var finishDateTime = DateTime.Now; var currentTest = _currentTestRuns.GetTest(testRun); var finalTest = testRun.Update(currentTest); var testGuid = finalTest.TestInfo.Guid.ToString(); var testPath = Path.Combine(TestsPath, testGuid); var fileName = finishDateTime.GetTestName(); _currentRun.RunSummary = _currentRun.RunSummary.Update(finalTest); finalTest.TestInfo.FileName = fileName; finalTest.RunGuid = _currentRunGuid; finalTest.TestInfo.Start = finalTest.TestInfo.Start.Equals(default(DateTime)) ? finishDateTime : finalTest.TestInfo.Start; finalTest.TestInfo.Finish = finalTest.TestInfo.Finish.Equals(default(DateTime)) ? finishDateTime : finalTest.TestInfo.Finish; finalTest.TestDuration = finalTest.TestDuration.Equals(0.0) ? (finalTest.TestInfo.Finish - finalTest.TestInfo.Start).TotalSeconds : finalTest.TestDuration; finalTest .Save(testPath, fileName); _currentTestRuns.Remove(currentTest); _currentRun.TestRunFiles.Add(Paths.GetRelativeTestRunPath(testGuid, fileName)); TestRunsHelper.SaveCurrentTestInfo(testPath, finalTest.TestInfo); if (Settings.RealTimeGeneration) { GenerateReport(DateTime.Now); } }); }