/// <summary> /// Run the test /// </summary> /// <param name="testName">Name of the test to be run</param> public static ResultStatus Run(string testName) { var qtTestNameFullPath = ""; var lastRunResultStatus = ResultStatus.Inconclusive; try { ReportFormats reportFormat; Enum.TryParse(TestConfiguration.ReportFormat, out reportFormat); var runResultsLocation = Path.Combine(TestConfiguration.TestRunSessionPath, testName); if (File.Exists(TestConfiguration.TestDataDrivenFile)) { testName = Utilities.GetTestListPlans()[0]; qtTestNameFullPath = Path.Combine(TestConfiguration.ProjectWorkspace, TestConfiguration.UiScripts, testName); TestConfiguration.RowCounter += 1; } UftTest = Open(testName); Thread.Sleep(5000); TestSettings(Settings.Run); TestSettings(Settings.LocalSystemMonitor); RunOptions(RuntimeOption.RunMode); if (reportFormat == ReportFormats.RRV) { //RunOptions(RunTimeOptions.AutoExport); } if (TestConfiguration.CaptureMovie) { RunOptions(RuntimeOption.ScreenCapture); } AddTestSourcesFolders(); AddResources(); Thread.Sleep(10000); RunResultsOptions runResults = new RunResultsOptions { ResultsLocation = runResultsLocation }; UftTest.Run(runResults); Thread.Sleep(5000); lastRunResultStatus = Utilities.GetLastTestRunResult(testName); if (File.Exists(TestConfiguration.TestDataDrivenFile)) { InjectEnvironmentInfo(Path.Combine(qtTestNameFullPath, "Action1", "Script.mts"), true); } } catch (Exception exception) { Log.Error(exception); } return(lastRunResultStatus); }
/// <summary> /// runs the given test QTP and returns results /// </summary> /// <param name="testResults">the test results object containing test info and also receiving run results</param> /// <returns></returns> private GuiTestRunResult ExecuteQTPRun(TestRunResults testResults) { RunResultsOptions options = CreateRunResultOptions(testResults); if (_runCancelled()) { return(HandleExecutionCanceled(testResults)); } try { ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerRunningTest, testResults.TestPath)); _qtpApplication.Options.Run.RunMode = _uftRunMode; _qtpApplication.Test.Run(options, false, _qtpParameters); WaitForTestExecutionComplete(testResults); if (_runCancelled()) { CloseTARobot(); return(HandleExecutionCanceled(testResults)); } return(AnalyzeLastRunResults(testResults)); } catch (Exception e2) { ConsoleWriter.WriteLine(string.Format(Resources.GeneralErrorWithStack, e2.Message, e2.StackTrace)); CloseTARobot(); GuiTestRunResult result = new GuiTestRunResult(); result.ReportPath = options.ResultsLocation; testResults.TestState = TestState.Error; testResults.ReportLocation = result.ReportPath; if (String.IsNullOrEmpty(testResults.ErrorDesc)) { testResults.ErrorDesc = Resources.QtpRunError; } result.IsSuccess = false; return(result); } }