Example #1
0
        public void DummyTestOperation()
        {
            string currentExecutingMethod = Utilities.GetCurrentMethod();
            var    resultsWriter          = new ResultsWriter(Constants.ParameterizedTest, currentExecutingMethod, true);
            var    loginTestData          = DummyOperationData.GetTestData();

            Parallel.ForEach(WebDrivers, (driver, loopState) =>
            {
                var testAsserter = new TestCaseAsserts();
                string currentWebBrowserString = Utilities.GetWebBrowser(driver);

                if (loginTestData != null)
                {
                    ResultReport testResultReport = new ResultReport();
                    string testFixtureName        = Utilities.GenerateTestFixtureName(this.GetType(), currentExecutingMethod,
                                                                                      currentWebBrowserString);
                    testResultReport.StartMethodTimerAndInitiateCurrentTestCase(testFixtureName, true);
                    try
                    {
                        /*
                         * Call page flow respective method here.
                         */

                        /*
                         * Call necessary assertion from TestCaseAsserts class here.
                         */
                        testResultReport.SetCurrentTestCaseOutcome(true, testAsserter.AssertionCount.ToString());
                    }
                    catch (Exception e)
                    {
                        string screenShotIdentifier = String.Format("{0} - {1}", "{ENTER AN IDENTIFIER (E.G. USER NAME}", currentExecutingMethod);
                        base.HandleException(e, screenShotIdentifier, driver, testResultReport, testAsserter, resultsWriter);
                        Assert.Fail("***** DummyTest Failed *****");
                    }
                    finally
                    {
                        testResultReport.StopMethodTimerAndFinishCurrentTestCase();
                        base.TestCases.Add(testResultReport.currentTestCase);
                    }
                }
            });

            resultsWriter.WriteResultsToFile(this.GetType().Name, TestCases);
        }
Example #2
0
 protected void HandleException(
     Exception ex,
     string screenshotIdentifier,
     IWebDriver webDriver,
     ResultReport resultReport,
     TestCaseAsserts asserts,
     ResultsWriter writer)
 {
     ScreenShotImage.CaptureScreenShot(
         webDriver,
         Utilities.CombineTestOutcomeString(Constants.ScreenshotError, screenshotIdentifier));
     resultReport.SetCurrentTestCaseOutcome(
         false,
         asserts.AssertionCount.ToString(),
         ex.Message,
         ex.StackTrace);
     resultReport.StopMethodTimerAndFinishCurrentTestCase();
     this.TestCases.Add(resultReport.currentTestCase);
     writer.WriteResultsToFile(this.GetType().Name, TestCases);
 }