/// <summary> /// Close UFT /// </summary> /// <param name="running"></param> /// <param name="close"></param> /// <param name="quitTool"></param> public static void Close(bool running = false, bool close = true, bool quitTool = true) { try { var isUftVisible = TestMonitor.IsUftVisible(); if (isUftVisible) { if (running) { UftTest.Stop(); Thread.Sleep(5000); } if (quitTool) { if (UftApplication == null) { UftApplication = new Application(); UftApplication.Quit(); Thread.Sleep(5000); UftApplication = null; } } } } catch (Exception exception) { Log.Error( "Unable to close/stop the long running. Possible with dead lock state. Terminating UFT to clear deadlock."); Log.Error(exception); } finally { Release(); } }
public static void Execute() { IList <string> testPlans; var stopWatch = new Stopwatch(); ResultStatus lastRunStatus = ResultStatus.Inconclusive; Log.Block("Marathon Engine", "Opened"); Log.Block("Verify UFT Heart Beat", "Opened"); Launch(); Log.Block("Verify UFT Heart Beat", "Closed"); Log.Block("Set Project WorkSpace", "Opened"); Utilities.SetProjectWorkSpace(); Log.Block("Set Project WorkSpace", "Closed"); Log.Block("Get Test Plans", "Opened"); if (File.Exists(TestConfiguration.TestDataDrivenFile)) { testPlans = Utilities.GetTestListPlans(true); } else { testPlans = Utilities.GetTestListPlans(); } Log.Block("Get Test Plans", "Closed"); Log.Block("Create Test Run Session Folder", "Opened"); Utilities.CreateTestRunFolders(); Utilities.CreateTestRunSessionFolder(); Log.Block("Create Test Run Session Folder", "Closed"); if (testPlans.Count > 0) { Log.Block("Test Run Session", "Opened"); Log.Normal("Duration Status Test Name"); Log.Normal("---------------------------------------------"); foreach (var testPlan in testPlans) { var activeTestPlan = testPlan; Parallel.Invoke ( () => { stopWatch.Start(); TestConfiguration.ActiveReportStack.Add(testPlan); lastRunStatus = Run(activeTestPlan); stopWatch.Stop(); }, () => { var currentSessionReportPath = Path.Combine(TestConfiguration.TestRunSessionPath, activeTestPlan, TestConfiguration.ReportFolderName); TestMonitor.WatchExecution(currentSessionReportPath); } ); var timeStamp = Utilities.GetFormattedTimeStamp(stopWatch.ElapsedMilliseconds); Utilities.PrintTestRunReport(activeTestPlan, lastRunStatus.ToString(), timeStamp); stopWatch.Reset(); if ((TestConfiguration.ConsecutiveFailureCheck.Contains("Active")) && (TestConfiguration.ConsecutiveFailureCounter == TestConfiguration.ConsecutiveMaximumFailure)) { break; } ResetAutomationTool(); } Log.Block("Test Run Session", "Closed"); Log.Block("Test Report Session", "Opened"); Utilities.PublishCrashReport(); Utilities.GenerateTestReports(testPlans); Utilities.SendReportMail(); Log.Block("Test Report Session", "Closed"); } else { Log.Error("No valid test(s) found in the list. Please check your properties file."); } Log.Block("Marathon Engine", "Closed"); }