Ejemplo n.º 1
0
        public void ExecuteTestCases(String ClienURL)
        {
            bool exceptionOccured = false;

            RunManager.TestCaseCount = ExecutionSession.lstTestCase.Count;
            IRunTestCases runTestCases = TestSetUp.GetRunTestCase();
            QCHelper      qcHelper     = null;

            if (HelperClass.QCUpdateResults)
            {
                qcHelper = new QCHelper();
            }

            foreach (TestCase testCase in ExecutionSession.lstTestCase)
            {
                try
                {
                    Console.WriteLine(testCase.TestCaseName + " Called");
                    runTestCases.CurrentTestCase = testCase;
                    runTestCases.RunTestCase();
                    if (HelperClass.QCUpdateResults)
                    {
                        qcHelper.UploadResults(testCase);
                    }
                }
                catch (Exception ex)
                {
                    exceptionOccured = true;
                    Logger.Log(ex.ToString());
                }
                RunManager.Progresscount++;
                TestcaseProgressBar(RunManager.Progresscount, RunManager.TestCaseCount);
            }
            //if (!exceptionOccured)
            //{
            //    try
            //    {
            //        SummaryReport report = new SummaryReport();
            //        report.GenerateSummaryReport();
            //        TestSetUp.AddFailedTCToExcel();
            //    }
            //    catch (Exception ex)
            //    {
            //        Logger.Log(ex.ToString());
            //    }
            //}
        }
Ejemplo n.º 2
0
        public void ExecuteMultipleBrowsers()
        {
            List <TestCase> lstRunTC;
            Report          rptTCMultiBrowser;
            DateTime        startTime;
            QCHelper        qcHelper = null;

            foreach (TestCase testCase in ExecutionSession.lstTestCase)
            {
                lstRunTC = ExecutionSession.lstAllBrowsersTC.Where(browserTC => browserTC.TestCaseName == testCase.TestCaseName).ToList();

                IRunTestCases      runTestCases;
                List <ThreadClass> lstThreads = new List <ThreadClass>();
                ThreadClass        storeThread;
                int count     = lstRunTC.Count;
                int threadCnt = 1;
                startTime = DateTime.Now;
                foreach (TestCase currentTestCase in lstRunTC)
                {
                    runTestCases = TestSetUp.GetRunTestCase();
                    runTestCases.CurrentTestCase = currentTestCase;
                    Thread runThread = new Thread(runTestCases.RunTestCase);
                    runThread.Name            = "Thread" + threadCnt;
                    storeThread               = new ThreadClass();
                    storeThread.ThreadName    = runThread.Name;
                    storeThread.currentThread = runThread;
                    lstThreads.Add(storeThread);
                    runThread.Start();
                    if (currentTestCase.Browser == Browser.FireFox)
                    {
                        Thread.Sleep(8000);
                    }
                    threadCnt++;
                }

                while (lstThreads.Any(thread => thread.currentThread.IsAlive))
                {
                }
                DateTime endTime       = DateTime.Now;
                TimeSpan timeTaken     = endTime.Subtract(startTime);
                string   executionTime = timeTaken.Minutes + " mins and "
                                         + timeTaken.Seconds + " secs";
                rptTCMultiBrowser = new Report();
                rptTCMultiBrowser.GenerateMultiBrowserDetailedReport(lstRunTC, timeTaken);
                try
                {
                    if (HelperClass.QCUpdateResults)
                    {
                        qcHelper = new QCHelper();
                        qcHelper.UploadResults(testCase);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.ToString());
                }
            }

            try
            {
                SummaryReport report = new SummaryReport();
                report.GenerateSummaryReport();
                TestSetUp.AddFailedTCToExcel();
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        //  public static string stateName = string.Empty;
        //  public static string cityName = string.Empty;

        public void RunTestCases()
        {
            ExecutionSession.startTime = DateTime.Now;
            bool exceptionOccured = false;

            try
            {
                TestSetUp.InitializeSetUp();
                //SendStartMail(ExecutionSession.dictCommonData["Environment"]);
                //Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occured during Test Setup. Please look into logs for more details.");
                Logger.Log(ex.ToString());
                Environment.Exit(0);
            }

            try
            {
                ExecutionSession.lstExecutedTestCases = new List <ExecutedTestCase>();
                ExecutionSession.lstErrorsteps        = new List <ErrorSteps>();
                foreach (clientList ClientList in ExecutionSession.lstClient)
                {
                    if (ClientProgresscount != 0)
                    {
                        ProgressBar(ClientProgresscount, ClientCount);
                    }
                    ExecutionSession.dictCommonData.Clear();
                    ExecutionSession.dictCommonData.Add("Environment", ClientList.EnvironmentName);
                    ExecutionSession.dictCommonData.Add("EnvironmentUrl", ClientList.clientUrl);
                    if (!HelperClass.runAllBrowsers && !HelperClass.runMultipleBrowsers &&
                        !HelperClass.runMultipleThreads)
                    {
                        ExecuteTestCases(ClientList.clientUrl);
                    }
                    else if (HelperClass.runAllBrowsers || HelperClass.runMultipleBrowsers)
                    {
                        ExecuteMultipleBrowsers();
                    }
                    else if (HelperClass.runMultipleThreads)
                    {
                        ExecuteMultipleTestCases();
                    }
                    Progresscount = 0;
                    ClientProgresscount++;
                    //Thread.Sleep(2000);
                    Console.Clear();
                    if (ClientProgresscount == ClientCount)
                    {
                        ProgressBar(ClientProgresscount, ClientCount);
                    }
                }
            }
            catch (Exception e)
            {
                exceptionOccured = true;
            }


            if (!exceptionOccured)
            {
                try
                {
                    SummaryReport report = new SummaryReport();
                    report.GenerateSummaryReport();
                    TestSetUp.AddFailedTCToExcel();
                    //  SendEndMail(ExecutionSession.dictCommonData["Environment"]);
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.ToString());
                }
            }

            if (HelperClass.sendEmail)
            {
                QCHelper qcHelper = new QCHelper();
                qcHelper.SendEmail();
            }
            Driver.QuitDriver(Driver.driver);
            //HTMLChartSummaryReport htmlChartSummaryReport = new HTMLChartSummaryReport();
            //htmlChartSummaryReport.generateSummaryReport();
            //System.Diagnostics.Process.Start(HelperClass.reportRunPath + "\\" + "SummaryReport" + ".html");
        }