Skip to content

Commit 6f1dc15

Browse files
committed
Java: Fixing NotYetImplementedRule
1 parent 1d8b79f commit 6f1dc15

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public abstract class JUnit4TestBase implements WrapsDriver {
6161
protected AppServer appServer;
6262
protected Pages pages;
6363
private static ThreadLocal<WebDriver> storedDriver = new ThreadLocal<>();
64-
private Browser browser;
6564
protected WebDriver driver;
6665
protected Wait<WebDriver> wait;
6766
protected Wait<WebDriver> shortWait;
@@ -84,21 +83,12 @@ public void prepareEnvironment() throws Exception {
8483

8584
@Rule
8685
public TestRule chain = RuleChain
87-
.outerRule(new DetectBrowserRule())
88-
.around(new TraceMethodNameRule())
86+
.outerRule(new TraceMethodNameRule())
8987
.around(new ManageDriverRule())
9088
.around(new SwitchToTopRule())
9189
.around(new NotYetImplementedRule())
9290
.around(new CoveringUpSauceErrorsRule());
9391

94-
private class DetectBrowserRule extends TestWatcher {
95-
@Override
96-
protected void starting(Description description) {
97-
browser = Browser.detect();
98-
super.starting(description);
99-
}
100-
}
101-
10292
private class TraceMethodNameRule extends TestWatcher {
10393
@Override
10494
protected void starting(Description description) {
@@ -116,6 +106,7 @@ protected void finished(Description description) {
116106
private class ManageDriverRule extends TestWatcher {
117107
@Override
118108
protected void starting(Description description) {
109+
super.starting(description);
119110
NeedsFreshDriver annotation = description.getAnnotation(NeedsFreshDriver.class);
120111
if (annotation != null) {
121112
removeDriver();
@@ -127,7 +118,6 @@ protected void starting(Description description) {
127118
} catch (Exception e) {
128119
throw new RuntimeException("Exception creating driver", e);
129120
}
130-
super.starting(description);
131121
}
132122

133123
@Override
@@ -184,6 +174,13 @@ private void dealWithSauceFailureIfNecessary(Throwable t) {
184174
}
185175

186176
private class NotYetImplementedRule implements TestRule {
177+
178+
private Browser browser;
179+
180+
public NotYetImplementedRule() {
181+
browser = Browser.detect();
182+
}
183+
187184
@Override
188185
public Statement apply(final Statement base, final Description description) {
189186
if (!isNotYetImplemented(description)) {

0 commit comments

Comments
 (0)