Skip to content

Commit

Permalink
fix: Ensure global properties are set also for junit 5 tests (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur- committed Mar 9, 2023
1 parent 90627a9 commit 129a65e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
public class BrowserExtension implements Extension, BeforeEachCallback,
ExecutionCondition, HasDriver, ParameterResolver {

static {
TestBench.ensureLoaded();
}

private static Logger getLogger() {
return LoggerFactory.getLogger(BrowserExtension.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
public abstract class TestBenchTestCase
implements HasDriver, HasTestBenchCommandExecutor, HasElementQuery {

static {
TestBench.ensureLoaded();
}

/**
* Specifies retry count, which is used to run same test several times. Can
* be changed by setting "com.vaadin.testbench.Parameters.maxAttempts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
*/
public class TestBench {

static {
LicenseChecker.checkLicenseFromStaticBlock("vaadin-testbench",
TestBenchVersion.testbenchVersion, null);
// Enable the Java 11+ HTTP client
System.setProperty("webdriver.http.factory", "jdk-http-client");
}

private static final Map<Class<?>, MethodFilter> methodFilters = new ConcurrentHashMap<>();

private static final class ElementMethodFilter implements MethodFilter {
Expand Down Expand Up @@ -83,11 +90,9 @@ public Object invoke(Object self, Method thisMethod, Method proceed,

}

static {
LicenseChecker.checkLicenseFromStaticBlock("vaadin-testbench",
TestBenchVersion.testbenchVersion, null);
// Enable the Java 11+ HTTP client
System.setProperty("webdriver.http.factory", "jdk-http-client");
public static void ensureLoaded() {
// This just ensures that the static initializers have been run so we
// can set global properties there for all tests
}

public static TestBenchDriverProxy createDriver(WebDriver driver) {
Expand Down

0 comments on commit 129a65e

Please sign in to comment.