org.xwiki.test.ui
Class TestDebugger
java.lang.Object
org.junit.rules.TestWatcher
org.xwiki.test.ui.TestDebugger
- All Implemented Interfaces:
- org.junit.rules.TestRule
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.
- Since:
- 4.3
- Version:
- $Id: 113fd89702dfca6ab833b73dc87675edd31de43f $
|
Constructor Summary |
TestDebugger(org.openqa.selenium.WebDriver driver)
Creates a new test rule that generates debugging information on test failure. |
|
Method Summary |
protected void |
failed(Throwable e,
org.junit.runner.Description description)
|
protected void |
starting(org.junit.runner.Description description)
|
protected void |
succeeded(org.junit.runner.Description description)
|
void |
takeScreenshot(String testName)
Captures a screenshot of the browser window. |
| Methods inherited from class org.junit.rules.TestWatcher |
apply, finished, skipped |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TestDebugger
public TestDebugger(org.openqa.selenium.WebDriver driver)
- Creates a new test rule that generates debugging information on test failure.
- Parameters:
driver - the object used to get the debugging information on test failure
starting
protected void starting(org.junit.runner.Description description)
- Overrides:
starting in class org.junit.rules.TestWatcher
succeeded
protected void succeeded(org.junit.runner.Description description)
- Overrides:
succeeded in class org.junit.rules.TestWatcher
failed
protected void failed(Throwable e,
org.junit.runner.Description description)
- Overrides:
failed in class org.junit.rules.TestWatcher
takeScreenshot
public void takeScreenshot(String testName)
- Captures a screenshot of the browser window.
- Parameters:
testName - the name of the file in which the screenshot will be taken. A ".png" suffix will be appended
Copyright © 2004-2013 XWiki. All Rights Reserved.