/// <summary> /// Start a Test and throw exception in errorcase /// </summary> /// <param name="typeName">typename of testcase to load</param> /// <param name="testsystem">string with the testsystem</param> /// <param name="language">string with the language</param> /// <param name="browser"></param> internal void InitializeTest(string typeName, string testsystem, string language, Browser browser) { TestHeader = String.Format("Testcase: {0} ({1}, {2}) on {3}", typeName, language, browser, testsystem); _testable = _testcaseProvider.GetTestableFromTypeName(typeName); _testable.GetLogLastTime(); _testable.SetupTest(WebDriverInitStrategy.SeleniumLocal, browser, testsystem, language); try { _testable.Test(); } catch (TaskCanceledException) { //Test is canceled. Do normal teardown } _testable.TeardownTest(); }
private TestResult HandleTest(WorkItem workItem) { TestResult testResult = new TestResult(); ITestable testable = null; List <string> log = new List <string>(); try { log.Add("Test on " + _nodename); /**1: Load Testclass **/ Console.WriteLine(@"Testing {0} {1} ({2}/{3})", workItem.Testcase.Name, workItem.Browser.Name, workItem.Testsystem.Name, workItem.Language.Languagecode); testable = LoadTestable(workItem); if (testable == null) { return new TestResult { TestState = TestState.NotAvailable } } ; /**2: Wait for branch get ready **/ WaitOnWebExceptions(workItem); /**3: Prepare Test **/ Browser browser = new Browser() { Browserstring = workItem.Browser.Browserstring, Versionsstring = workItem.Browser.Versionsstring }; testable.SetupTest(WebDriverInitStrategy.SeleniumLocal, browser, workItem.Testsystem.Url, workItem.Language.Languagecode); /**4: Run Test **/ testable.Test(); testResult.TestState = TestState.Success; } catch (NotSupportedException notSupportedException) { Error error = CreateErrorFromException(notSupportedException); testResult.TestState = TestState.NotSupported; testResult.Error = error; } catch (TaskCanceledException taskCanceledException) { Error error = CreateErrorFromException(taskCanceledException); testResult.TestState = TestState.Canceled; testResult.Error = error; } catch (Exception exception) { ServerErrorModel serverException = null; try { if (testable != null) { serverException = testable.CheckForServerError(); } } catch { //Error catching serverException } Error error = CreateErrorFromException(exception); if (serverException != null) { error.Type = serverException.Type; error.Message = serverException.Message; error.InnerException = serverException.InnerException; //objError.StackTrace = serverException.StackTrace; Keep error stacktrace. } testResult.TestState = TestState.Error; testResult.Error = error; if (testable != null) { testResult.Screenshot = testable.SaveScreenshot(""); } } finally { if (testable != null) { testable.TeardownTest(); log.AddRange(testable.GetLogLastTime()); } testResult.Log = log; } return(testResult); }