Skip to content

Commit 0e6eaec

Browse files
committed
working on junit5 update / WebDriverTestCases (wip)
1 parent 6edd340 commit 0e6eaec

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/test/java/org/htmlunit/SimpleWebTestCase.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
import org.htmlunit.html.HtmlPage;
2525
import org.htmlunit.javascript.JavaScriptEngine;
26-
import org.junit.After;
27-
import org.junit.Before;
26+
import org.junit.jupiter.api.AfterEach;
27+
import org.junit.jupiter.api.BeforeEach;
2828

2929
/**
3030
* A simple WebTestCase which doesn't require server to run, and doens't use WebDriver.
@@ -229,19 +229,23 @@ protected final HtmlPage loadPageWithAlerts(final String html, final URL url, fi
229229
/**
230230
* Reads the number of JS threads remaining from unit tests run before.
231231
* This should be always 0.
232+
* @throws Exception in case of error
232233
*/
233-
@Before
234-
public void before() {
234+
@BeforeEach
235+
public void before() throws Exception {
235236
if (webClient_ != null && webClient_.getJavaScriptEngine() instanceof JavaScriptEngine) {
236-
assertTrue(getJavaScriptThreads().isEmpty());
237+
if (!getJavaScriptThreads().isEmpty()) {
238+
Thread.sleep(200);
239+
}
240+
assertTrue("There are already JS threads running before the test", getJavaScriptThreads().isEmpty());
237241
}
238242
}
239243

240244
/**
241245
* Cleanup after a test.
242246
*/
243247
@Override
244-
@After
248+
@AfterEach
245249
public void releaseResources() {
246250
super.releaseResources();
247251
boolean rhino = false;

0 commit comments

Comments
 (0)