Exemple #1
0
        public void Setup()
        {
            // Save a reference to the current Test's log in its TestContext
            TestContext.Set("log", "");


            // Log the test attributes of the current [Test]
            Log.StandardAttributes();

            // Log Before Action
            Log.BeforeAction();



            // Perform the action
            try
            {
                BeginReporting();

                _reportingTasks.InitializeTest();
                Session.Create();
                // Set WebDriver's window to full screen
                AppBase.Maximize();

                // Delete all cookies
                AppBase.DeleteAllCookies();


                // Logging - After action success
                Log.Success();
            }
            catch (Exception e)
            {
                // Logging - After action exception
                Log.Failure(e.Message);
                // Fail current test
                Assert.Fail(e.Message);
            }
            finally
            {
                // Logging - After action
                Log.Finally();
            }
        }
Exemple #2
0
        public void TearDown()
        {
            // Log Before Action
            Log.BeforeAction();


            // Perform the action
            try
            {
                // Check if the Test that is ending was a failure
                if (NUnit.Framework.TestContext.CurrentContext.Result.Outcome != NUnit.Framework.Interfaces.ResultState.Success)
                {
                    // Take screenshot of the failure state
                    AppBase.TakeScreenshot();
                }
                _reportingTasks.FinalizeTest();
                //_reportingTasks.CleanUpReporting();
                // Quit this driver, closing every associated window.
                AppBase.Quit();

                // Logging - After action success
                Log.Success();
            }
            catch (Exception e)
            {
                // Logging - After action exception
                Log.Failure(e.Message);
                // Fail current test
                Assert.Fail(e.Message);
            }
            finally
            {
                // Logging - After action
                Log.Finally();
                // Print log to console (for Visual Studio and Bamboo)
                string log = TestContext.Get("log").ToString();
                if (log.Length > 0)
                {
                    Console.WriteLine(log);
                }
            }
        }