Пример #1
0
        public static void IsTrue(bool actualResult, bool fail = false, string message = "Step failed")
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";

            try
            {
                Assert.IsTrue(actualResult);
            }
            catch (Exception ex)
            {
                if (fail)
                {
                    test.Log(LogStatus.Fatal, stackTrace + message);
                    Assert.Fail(message);
                    string screenShotPath = GetScreenshot.Capture(driver, "ScreenShotName");
                    test.Log(LogStatus.Fatal, "Snapshot below: " + test.AddScreenCapture(screenShotPath));
                }
                else
                {
                    test.Log(LogStatus.Fail, stackTrace + message);
                    string screenShotPath = GetScreenshot.Capture(driver, "ScreenShotName");
                    test.Log(LogStatus.Fatal, "Snapshot below: " + test.AddScreenCapture(screenShotPath));
                }
            }
        }
Пример #2
0
        public static void GetResult()
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";


            if (status == TestStatus.Failed)
            {
                string screenShotPath = GetScreenshot.Capture(driver, "ScreenShotName");
                test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(screenShotPath));
            }
        }
Пример #3
0
        public static void Equals(string expectedResult, string actualResult, bool fail = false, string message = "")
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";

            try
            {
                Assert.AreEqual(expectedResult, actualResult);
            }
            catch (Exception ex)
            {
                if (fail)
                {
                    test.Log(LogStatus.Fatal, stackTrace + message);
                    Assert.Fail(message);
                    test.Log(LogStatus.Fatal, "Snapshot below: " + test.AddScreenCapture(GetScreenshot.Capture(driver, "ScreenShotName")));
                }
                else
                {
                    test.Log(LogStatus.Fail, stackTrace + message);
                }
                test.Log(LogStatus.Fatal, "Snapshot below: " + test.AddScreenCapture(GetScreenshot.Capture(driver, "ScreenShotName")));
            }
        }