Skip to content

Commit 4480d12

Browse files
committed
[java] restore testEnvironment in JavaScriptTestSuite
1 parent 6f41ef9 commit 4480d12

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

java/test/org/openqa/selenium/javascript/JavaScriptTestSuite.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
import java.util.function.Function;
3131
import java.util.function.Supplier;
3232
import org.junit.jupiter.api.AfterEach;
33+
import org.junit.jupiter.api.BeforeEach;
3334
import org.junit.jupiter.api.DynamicTest;
3435
import org.junit.jupiter.api.TestFactory;
3536
import org.openqa.selenium.WebDriver;
3637
import org.openqa.selenium.build.InProject;
3738
import org.openqa.selenium.environment.GlobalTestEnvironment;
39+
import org.openqa.selenium.environment.InProcessTestEnvironment;
40+
import org.openqa.selenium.environment.TestEnvironment;
3841
import org.openqa.selenium.environment.webserver.AppServer;
3942
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
4043

@@ -45,6 +48,8 @@ class JavaScriptTestSuite {
4548

4649
private final long timeout;
4750

51+
private TestEnvironment testEnvironment;
52+
4853
public JavaScriptTestSuite() {
4954
this.timeout = Math.max(0, Long.getLong("js.test.timeout", 0));
5055
this.driverSupplier = new DriverSupplier();
@@ -54,8 +59,17 @@ private static boolean isBazel() {
5459
return InProject.findRunfilesRoot() != null;
5560
}
5661

62+
@BeforeEach
63+
public void setup() {
64+
// this field is actually in use, javascript test do access it
65+
testEnvironment = GlobalTestEnvironment.getOrCreate(InProcessTestEnvironment::new);
66+
}
67+
5768
@AfterEach
5869
public void teardown() throws IOException {
70+
if (testEnvironment != null) {
71+
testEnvironment.stop();
72+
}
5973
if (driverSupplier != null) {
6074
((Closeable) driverSupplier).close();
6175
}

0 commit comments

Comments
 (0)