Exemple #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());
            //    }
            //}
        }
Exemple #2
0
        public void ExecuteMultipleTestCases()
        {
            IRunTestCases runTestCases = TestSetUp.GetRunTestCase();

            List <ThreadClass> lstThreads = new List <ThreadClass>();
            ThreadClass        storeThread;
            int count            = ExecutionSession.lstTestCase.Count;
            int runTestCaseCount = 0;

            if (ExecutionSession.lstTestCase.Count < HelperClass.runNoofThreads)
            {
                runTestCaseCount = ExecutionSession.lstTestCase.Count;
            }
            else
            {
                runTestCaseCount = HelperClass.runNoofThreads;
            }
            int threadCnt = 0;

            while (threadCnt < count)
            {
                if (threadCnt == 0)
                {
                    for (int iLp = 1; iLp <= runTestCaseCount; iLp++)
                    {
                        TestCase testCase = ExecutionSession.lstTestCase[threadCnt];
                        runTestCases.CurrentTestCase = testCase;
                        Thread runThread = new Thread(runTestCases.RunTestCase);
                        runThread.Name            = "Thread" + iLp;
                        storeThread               = new ThreadClass();
                        storeThread.ThreadName    = runThread.Name;
                        storeThread.currentThread = runThread;
                        lstThreads.Add(storeThread);
                        runThread.Start();
                        threadCnt++;
                        Console.WriteLine("Threads executed is : " + threadCnt);
                        Thread.Sleep(700);
                    }
                }
                else
                {
                    foreach (ThreadClass currentThread in lstThreads)
                    {
                        if (currentThread.currentThread.IsAlive == false)
                        {
                            if (threadCnt < count)
                            {
                                Console.WriteLine("Thread  " + currentThread.ThreadName + " is alive :" + currentThread.currentThread.IsAlive);
                                runTestCases = TestSetUp.GetRunTestCase();
                                TestCase testCase = ExecutionSession.lstTestCase[threadCnt];
                                runTestCases.CurrentTestCase = testCase;
                                Thread runThread = new Thread(runTestCases.RunTestCase);
                                runThread.Name = currentThread.ThreadName;
                                currentThread.currentThread = runThread;
                                runThread.Start();
                                threadCnt++;
                                Console.WriteLine("Threads executed is : " + threadCnt);
                                Thread.Sleep(700);
                            }
                        }
                    }
                }
            }

            while (lstThreads.Any(thread => thread.currentThread.IsAlive))
            {
            }

            try
            {
                SummaryReport report = new SummaryReport();
                report.GenerateSummaryReport();
                TestSetUp.AddFailedTCToExcel();
            }
            catch (Exception ex)
            {
                Logger.Log(ex.ToString());
            }
        }