Skip to content

Commit

Permalink
[java] restore testEnvironment in JavaScriptTestSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
joerg1985 committed Nov 4, 2024
1 parent 6f41ef9 commit 4480d12
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions java/test/org/openqa/selenium/javascript/JavaScriptTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
import java.util.function.Function;
import java.util.function.Supplier;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.build.InProject;
import org.openqa.selenium.environment.GlobalTestEnvironment;
import org.openqa.selenium.environment.InProcessTestEnvironment;
import org.openqa.selenium.environment.TestEnvironment;
import org.openqa.selenium.environment.webserver.AppServer;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

Expand All @@ -45,6 +48,8 @@ class JavaScriptTestSuite {

private final long timeout;

private TestEnvironment testEnvironment;

public JavaScriptTestSuite() {
this.timeout = Math.max(0, Long.getLong("js.test.timeout", 0));
this.driverSupplier = new DriverSupplier();
Expand All @@ -54,8 +59,17 @@ private static boolean isBazel() {
return InProject.findRunfilesRoot() != null;
}

@BeforeEach
public void setup() {
// this field is actually in use, javascript test do access it
testEnvironment = GlobalTestEnvironment.getOrCreate(InProcessTestEnvironment::new);
}

@AfterEach
public void teardown() throws IOException {
if (testEnvironment != null) {
testEnvironment.stop();
}
if (driverSupplier != null) {
((Closeable) driverSupplier).close();
}
Expand Down

0 comments on commit 4480d12

Please sign in to comment.