public class ReportTestWatcher extends ProviderTestWatcher
Report
. If a tests fails it
will also attempt to append any exceptions that occurred to the report.
Example usage of this watcher:
import org.junit.*;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import edu.uci.qa.browserdriver.BrowserDriver;
import edu.uci.qa.browserdriver.testing.BrowserProvider;
import edu.uci.qa.browserdriver.testing.ReportTestWatcher;
public class ReportTest implements BrowserProvider {
BrowserDriver driver = null;
@Rule
public ReportTestWatcher watcher = new ReportTestWatcher(this);
@Before
public void createBrowser() {
driver = BrowserDriver.createBrowser();
}
@After
public void quitBrowser() {
driver.quit();
}
@Test
public void basicTest() throws Throwable {
driver.get("http://www.google.com");
driver.sendKeys(By.xpath("//*[@name='q']"), "webdriver").submit();
driver.waitUntil(
ExpectedConditions.presenceOfElementLocated(
By.xpath("//*[@id='rso' or @id='resultStats']")));
Assert.assertEquals("webdriver - Google Search", driver.getTitle());
}
@Override
public BrowserDriver getBrowser() {
return driver;
}
}
provider, verboseMode
Constructor and Description |
---|
ReportTestWatcher(Provider provider) |
ReportTestWatcher(Provider provider,
boolean verboseMode) |
Modifier and Type | Method and Description |
---|---|
protected void |
failed(Throwable e,
org.junit.runner.Description description) |
protected void |
skipped(org.junit.AssumptionViolatedException e,
org.junit.runner.Description description) |
protected void |
succeeded(org.junit.runner.Description description) |
public ReportTestWatcher(Provider provider)
public ReportTestWatcher(Provider provider, boolean verboseMode)
protected void skipped(org.junit.AssumptionViolatedException e, org.junit.runner.Description description)
skipped
in class org.junit.rules.TestWatcher
protected void succeeded(org.junit.runner.Description description)
succeeded
in class org.junit.rules.TestWatcher
protected void failed(Throwable e, org.junit.runner.Description description)
failed
in class org.junit.rules.TestWatcher
Copyright © 2019. All rights reserved.