public static GetTestStateFromReport ( TestRunResults runDesc ) : TestState | ||
runDesc | TestRunResults | |
Résultat | TestState |
private void AnalyzeRunResult(TestRunResults runResult) { //if fail was terminated before this step, continue if (runResult.TestState != TestState.Failed) { if (runResult.TestState != TestState.Error) { Helper.GetTestStateFromReport(runResult); } else { if (string.IsNullOrEmpty(runResult.ErrorDesc)) { if (RunCancelled()) { runResult.ErrorDesc = HpToolsLauncher.Properties.Resources.ExceptionUserCancelled; } else { runResult.ErrorDesc = HpToolsLauncher.Properties.Resources.ExceptionExternalProcess; } } runResult.ReportLocation = null; runResult.TestState = TestState.Error; } } if (runResult.TestState == TestState.Passed && runResult.HasWarnings) { runResult.TestState = TestState.Warning; ConsoleWriter.WriteLine(Resources.FsRunnerTestDoneWarnings); } else { ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestDone, runResult.TestState)); } ConsoleWriter.WriteLine(DateTime.Now.ToString(Launcher.DateFormat) + " Test complete: " + runResult.TestPath + "\n-------------------------------------------------------------------------------------------------------"); UpdateCounters(runResult.TestState); }
/// <summary> /// runs all tests given to this runner and returns a suite of run resutls /// </summary> /// <returns>The rest run results for each test</returns> public override TestSuiteRunResults Run() { //create a new Run Results object TestSuiteRunResults activeRunDesc = new TestSuiteRunResults(); double totalTime = 0; try { var start = DateTime.Now; foreach (var test in _tests) { if (RunCancelled()) { break; } var testStart = DateTime.Now; string errorReason = string.Empty; TestRunResults runResult = null; try { runResult = RunHPToolsTest(test, ref errorReason); } catch (Exception ex) { runResult = new TestRunResults(); runResult.TestState = TestState.Error; runResult.ErrorDesc = ex.Message; runResult.TestName = test.TestName; } //get the original source for this test, for grouping tests under test classes runResult.TestGroup = test.TestGroup; activeRunDesc.TestRuns.Add(runResult); //if fail was terminated before this step, continue if (runResult.TestState != TestState.Failed) { if (runResult.TestState != TestState.Error) { Helper.GetTestStateFromReport(runResult); } else { if (string.IsNullOrEmpty(runResult.ErrorDesc)) { if (RunCancelled()) { runResult.ErrorDesc = HpToolsLauncher.Properties.Resources.ExceptionUserCancelled; } else { runResult.ErrorDesc = HpToolsLauncher.Properties.Resources.ExceptionExternalProcess; } } runResult.ReportLocation = null; runResult.TestState = TestState.Error; } } if (runResult.TestState == TestState.Passed && runResult.HasWarnings) { runResult.TestState = TestState.Warning; ConsoleWriter.WriteLine(Resources.FsRunnerTestDoneWarnings); } else { ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestDone, runResult.TestState)); } ConsoleWriter.WriteLine(DateTime.Now.ToString(Launcher.DateFormat) + " Test complete: " + runResult.TestPath + "\n-------------------------------------------------------------------------------------------------------"); UpdateCounters(runResult.TestState); var testTotalTime = (DateTime.Now - testStart).TotalSeconds; } totalTime = (DateTime.Now - start).TotalSeconds; } finally { activeRunDesc.NumTests = _tests.Count; activeRunDesc.NumErrors = _errors; activeRunDesc.TotalRunTime = TimeSpan.FromSeconds(totalTime); activeRunDesc.NumFailures = _fail; foreach (IFileSysTestRunner cleanupRunner in _colRunnersForCleanup.Values) { cleanupRunner.CleanUp(); } } return(activeRunDesc); }
/// <summary> /// runs all tests given to this runner and returns a suite of run results /// </summary> /// <returns>The rest run results for each test</returns> public override TestSuiteRunResults Run() { //create a new Run Results object TestSuiteRunResults activeRunDesc = new TestSuiteRunResults(); double totalTime = 0; try { var start = DateTime.Now; Dictionary <string, int> indexList = new Dictionary <string, int>(); foreach (var test in _tests) { indexList[test.TestPath] = 0; } Dictionary <string, int> rerunList = createDictionary(_tests); foreach (var test in _tests) { if (indexList[test.TestPath] == 0) { indexList[test.TestPath] = 1; } if (RunCancelled()) { break; } var testStart = DateTime.Now; string errorReason = string.Empty; TestRunResults runResult = null; try { runResult = RunHpToolsTest(test, ref errorReason); } catch (Exception ex) { runResult = new TestRunResults { TestState = TestState.Error, ErrorDesc = ex.Message, TestName = test.TestName, TestPath = test.TestPath }; } //get the original source for this test, for grouping tests under test classes runResult.TestGroup = test.TestGroup; activeRunDesc.TestRuns.Add(runResult); //if fail was terminated before this step, continue if (runResult.TestState != TestState.Failed) { if (runResult.TestState != TestState.Error) { Helper.GetTestStateFromReport(runResult); } else { if (string.IsNullOrEmpty(runResult.ErrorDesc)) { runResult.ErrorDesc = RunCancelled() ? HpToolsLauncher.Properties.Resources.ExceptionUserCancelled : HpToolsLauncher.Properties.Resources.ExceptionExternalProcess; } runResult.ReportLocation = null; runResult.TestState = TestState.Error; } } if (runResult.TestState == TestState.Passed && runResult.HasWarnings) { runResult.TestState = TestState.Warning; ConsoleWriter.WriteLine(Resources.FsRunnerTestDoneWarnings); } else { ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestDone, runResult.TestState)); } ConsoleWriter.WriteLine(DateTime.Now.ToString(Launcher.DateFormat) + " Test complete: " + runResult.TestPath + "\n-------------------------------------------------------------------------------------------------------"); UpdateCounters(runResult.TestState); var testTotalTime = (DateTime.Now - testStart).TotalSeconds; //create test folders if (rerunList[test.TestPath] > 0) { if (!Directory.Exists(Path.Combine(test.TestPath, "Report1"))) { rerunList[test.TestPath]--; } else { indexList[test.TestPath]++; rerunList[test.TestPath]--; } } //update report folder String uftReportDir = Path.Combine(test.TestPath, "Report"); String uftReportDirNew = Path.Combine(test.TestPath, "Report" + indexList[test.TestPath]); try { if (Directory.Exists(uftReportDir)) { if (Directory.Exists(uftReportDirNew)) { Helper.DeleteDirectory(uftReportDirNew); } Directory.Move(uftReportDir, uftReportDirNew); } } catch { System.Threading.Thread.Sleep(1000); Directory.Move(uftReportDir, uftReportDirNew); } } totalTime = (DateTime.Now - start).TotalSeconds; } finally { activeRunDesc.NumTests = _tests.Count; activeRunDesc.NumErrors = _errors; activeRunDesc.TotalRunTime = TimeSpan.FromSeconds(totalTime); activeRunDesc.NumFailures = _fail; foreach (IFileSysTestRunner cleanupRunner in _colRunnersForCleanup.Values) { cleanupRunner.CleanUp(); } } return(activeRunDesc); }