Class TestDebugger

  • All Implemented Interfaces:

    public class TestDebugger
    extends org.junit.rules.TestWatcher
    Generates debugging information on test failure:
    • captures a screenshot of the browser window
    • logs the URL of the current page
    • logs the source of the current page
    NOTE: The reason we also log when a test starts and passes is simply to overcome a deficiency in error reporting in Jenkins. The reason is that Jenkins bases its test reporting on the Maven Surefire plugin reporting which itself is using a file to report test status. Since ui-tests are using a test suite, PageObjectSuite, there's only a single file generated and it's only generated when all tests have finished executing. Thus if a test hangs there won't be any file generated and looking at the Jenkins UI it won't be possible to see which tests have executed.

    Normally each JUnit Test Runner knows what test is executing and when it's finished and thus can report them in its own console (as this is the case for IDEs for example). Again the issue here is that Jenkins doesn't have any JUnit Test Runner but instead is calling JUnit by delegation to the Maven Surefire plugin.

    $Id: 113fd89702dfca6ab833b73dc87675edd31de43f $
    • Constructor Detail

      • TestDebugger

        public TestDebugger​(org.openqa.selenium.WebDriver driver)
        Creates a new test rule that generates debugging information on test failure.
        driver - the object used to get the debugging information on test failure
    • Method Detail

      • starting

        protected void starting​(org.junit.runner.Description description)
        starting in class org.junit.rules.TestWatcher
      • succeeded

        protected void succeeded​(org.junit.runner.Description description)
        succeeded in class org.junit.rules.TestWatcher
      • failed

        protected void failed​(Throwable e,
                              org.junit.runner.Description description)
        failed in class org.junit.rules.TestWatcher
      • takeScreenshot

        public void takeScreenshot​(String testName)
        Captures a screenshot of the browser window.
        testName - the name of the file in which the screenshot will be taken. A ".png" suffix will be appended