Skip to content

Commit

Permalink
Java: Fixing NotYetImplementedRule
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Jan 30, 2016
1 parent 1d8b79f commit 6f1dc15
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public abstract class JUnit4TestBase implements WrapsDriver {
protected AppServer appServer;
protected Pages pages;
private static ThreadLocal<WebDriver> storedDriver = new ThreadLocal<>();
private Browser browser;
protected WebDriver driver;
protected Wait<WebDriver> wait;
protected Wait<WebDriver> shortWait;
Expand All @@ -84,21 +83,12 @@ public void prepareEnvironment() throws Exception {

@Rule
public TestRule chain = RuleChain
.outerRule(new DetectBrowserRule())
.around(new TraceMethodNameRule())
.outerRule(new TraceMethodNameRule())
.around(new ManageDriverRule())
.around(new SwitchToTopRule())
.around(new NotYetImplementedRule())
.around(new CoveringUpSauceErrorsRule());

private class DetectBrowserRule extends TestWatcher {
@Override
protected void starting(Description description) {
browser = Browser.detect();
super.starting(description);
}
}

private class TraceMethodNameRule extends TestWatcher {
@Override
protected void starting(Description description) {
Expand All @@ -116,6 +106,7 @@ protected void finished(Description description) {
private class ManageDriverRule extends TestWatcher {
@Override
protected void starting(Description description) {
super.starting(description);
NeedsFreshDriver annotation = description.getAnnotation(NeedsFreshDriver.class);
if (annotation != null) {
removeDriver();
Expand All @@ -127,7 +118,6 @@ protected void starting(Description description) {
} catch (Exception e) {
throw new RuntimeException("Exception creating driver", e);
}
super.starting(description);
}

@Override
Expand Down Expand Up @@ -184,6 +174,13 @@ private void dealWithSauceFailureIfNecessary(Throwable t) {
}

private class NotYetImplementedRule implements TestRule {

private Browser browser;

public NotYetImplementedRule() {
browser = Browser.detect();
}

@Override
public Statement apply(final Statement base, final Description description) {
if (!isNotYetImplemented(description)) {
Expand Down

0 comments on commit 6f1dc15

Please sign in to comment.