Esempio n. 1
0
        public void AnalyseTestResult(string testStep, LogStatus status, string errorMessage)
        {
            IWebDriver driver        = BaseClass.GetDriver();
            var        testClassName = TestContext.CurrentContext.Test.ClassName.Substring(TestContext.CurrentContext.Test.ClassName.LastIndexOf(".") + 1);

            if (errorMessage == "")
            {
                errorMessage = TestContext.CurrentContext.Result.Message;
            }

            //  var testCaseName = "<b>" + TestContext.CurrentContext.Test.MethodName + "</b>";
            var testStepDec = "<b>" + testStep + "</b>";

            string screenShotPath = TakeScreenshot(driver);

            if (status.Equals(LogStatus.Fail))
            {
                var Details = string.Format(HtmlContent, GetTestCaseFailureReason(errorMessage), errorMessage, TestContext.CurrentContext.Result.StackTrace, test.AddScreenCapture(screenShotPath), StyleScript);

                test.Log(LogStatus.Fail, testStepDec, Details);
                TestScenarioStatus = false;
            }
            else if (status.Equals(LogStatus.Pass))
            {
                var Details = string.Format(HtmlContent2, "Test case passed.", "As per Expected Result", test.AddScreenCapture(screenShotPath), StyleScript);

                test.Log(LogStatus.Pass, testStepDec, Details);
            }
            else if (status.Equals(TestStatus.Skipped))
            {
                var Details = string.Format(HtmlContent3, "Test case skipped.", " Not Executed need to re-Run", test.AddScreenCapture(screenShotPath), StyleScript);

                test.Log(LogStatus.Skip, testStepDec, Details);
            }
        }
Esempio n. 2
0
        private void LogSucessoEAddPrint(bool aux, LogStatus logStatus)
        {
            ExtentReport.EndTest(ExtentReport.test);

            if (aux == true)
            {
                if (logStatus.Equals(LogStatus.Pass))
                {
                    if (ExtentReport.image != null)
                    {
                        ExtentReport.test.Log(LogStatus.Pass, "Teste executado com sucesso!" + ExtentReport.image);
                    }
                    else
                    {
                        ExtentReport.test.Log(LogStatus.Pass, "Teste executado com sucesso!");
                    }
                }
                else
                {
                    if (ExtentReport.image != null)
                    {
                        ExtentReport.test.Log(LogStatus.Fail, "Falha na execução do cenário!" + ExtentReport.image);
                    }
                    else
                    {
                        ExtentReport.test.Log(LogStatus.Fail, "Falha na execução do cenário!");
                    }
                }
            }
            else
            {
                if (ExtentReport.image != null)
                {
                    ExtentReport.test.Log(LogStatus.Fail, "Teste com falha, favor verificar a evidência do teste." + ExtentReport.image);
                }
                else
                {
                    ExtentReport.test.Log(LogStatus.Fail, "Teste com falha, favor verificar a evidência do teste.");
                }
            }
        }