예제 #1
0
        private void Execute_TestCase()
        {
            int iTotalTestCases = ExcelUtils.GetRowCount(Constants.Sheet_TestCases);

            for (int iTestcase = 1; iTestcase < iTotalTestCases; iTestcase++)
            {
                iOutcome       = 1;
                sTestCaseID    = ExcelUtils.GetCellData(iTestcase, Constants.Col_ID, Constants.Sheet_TestCases);
                sTestCaseTitle = ExcelUtils.GetCellData(iTestcase, Constants.Col_Title, Constants.Sheet_TestCases);
                sTestCaseDesc  = ExcelUtils.GetCellData(iTestcase, Constants.Col_Description, Constants.Sheet_TestCases);
                sRunMode       = ExcelUtils.GetCellData(iTestcase, Constants.Col_RunMode, Constants.Sheet_TestCases);

                if (sRunMode.Equals("Yes"))
                {
                    Log.StartTestCase(sTestCaseID);
                    ExtentReporter.CreateTest(sTestCaseID + "_" + sTestCaseTitle, sTestCaseDesc);
                    ExtentReporter.StartTestCase(sTestCaseID + "_" + sTestCaseTitle);
                    iTestStep     = ExcelUtils.GetRowContains(sTestCaseID, Constants.Col_TestCaseID, Constants.Sheet_TestSteps);
                    iTestLastStep = ExcelUtils.GetTestStepsCount(Constants.Sheet_TestSteps, sTestCaseID, iTestStep);
                    iOutcome      = 1;
                    for (; iTestStep < iTestLastStep; iTestStep++)
                    {
                        sActionKeyword = ExcelUtils.GetCellData(iTestStep, Constants.Col_ActionKeyword, Constants.Sheet_TestSteps);
                        sPageObject    = ExcelUtils.GetCellData(iTestStep, Constants.Col_PageObject, Constants.Sheet_TestSteps);
                        sData          = ExcelUtils.GetCellData(iTestStep, Constants.Col_DataSet, Constants.Sheet_TestSteps);
                        sTestStepDesc  = ExcelUtils.GetCellData(iTestStep, Constants.Col_TestStepDesc, Constants.Sheet_TestSteps);
                        ExtentReporter.CreateNode(sTestStepDesc);
                        Execute_Actions();

                        if (iOutcome == 3)
                        {
                            ExcelUtils.SetCellData(Outcome.Error.ToString(), iTestcase, Constants.Col_Result, Constants.Sheet_TestCases);
                            Log.EndTestCase(sTestCaseID);
                            ExtentReporter.Error("TestCase " + sTestCaseID + "_" + sTestCaseTitle + " Error");
                            ExtentReporter.EndTestCase(sTestCaseID + "_" + sTestCaseTitle);
                            Assert.Fail();
                            break;
                        }
                    }

                    if (iOutcome == 1)
                    {
                        ExcelUtils.SetCellData(Outcome.Pass.ToString(), iTestcase, Constants.Col_Result, Constants.Sheet_TestCases);
                        Log.EndTestCase(sTestCaseID);
                        ExtentReporter.Pass("TestCase " + sTestCaseID + "_" + sTestCaseTitle + " Passed");
                        ExtentReporter.EndTestCase(sTestCaseID + "_" + sTestCaseTitle);
                    }
                    else if (iOutcome == 2)
                    {
                        ExcelUtils.SetCellData(Outcome.Fail.ToString(), iTestcase, Constants.Col_Result, Constants.Sheet_TestCases);
                        Log.EndTestCase(sTestCaseID);
                        ExtentReporter.Fail("TestCase " + sTestCaseID + "_" + sTestCaseTitle + " Failed");
                        ExtentReporter.EndTestCase(sTestCaseID + "_" + sTestCaseTitle);
                    }
                }
            }
        }