Skip to content

Commit b8e1e1d

Browse files
authored
chore: remove isolated tests (#984)
1 parent a074573 commit b8e1e1d

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,14 @@ jobs:
3131
- name: Build & Install
3232
run: mvn -B install -D skipTests --no-transfer-progress
3333
- name: Run tests
34-
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end
34+
run: mvn test --no-transfer-progress --fail-at-end
3535
env:
3636
BROWSER: ${{ matrix.browser }}
3737
- name: Run tracing tests w/ sources
38-
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end -D test=*TestTracing*
38+
run: mvn test --no-transfer-progress --fail-at-end -D test=*TestTracing*
3939
env:
4040
BROWSER: ${{ matrix.browser }}
4141
PLAYWRIGHT_JAVA_SRC: src/test/java
42-
- name: Run driver throw tests
43-
run: mvn test -Dgroups=driverThrowTest --no-transfer-progress --fail-at-end
44-
env:
45-
BROWSER: ${{ matrix.browser }}
4642
- name: Test Spring Boot Starter
4743
shell: bash
4844
env:
@@ -83,12 +79,7 @@ jobs:
8379
- name: Build & Install
8480
run: mvn -B install -D skipTests --no-transfer-progress
8581
- name: Run tests
86-
run: mvn test -DexcludedGroups=isolated --no-transfer-progress --fail-at-end
87-
env:
88-
BROWSER: chromium
89-
BROWSER_CHANNEL: ${{ matrix.browser-channel }}
90-
- name: Run driver throw tests
91-
run: mvn test -Dgroups=driverThrowTest --no-transfer-progress --fail-at-end
82+
run: mvn test --no-transfer-progress --fail-at-end
9283
env:
9384
BROWSER: chromium
9485
BROWSER_CHANNEL: ${{ matrix.browser-channel }}

driver-bundle/src/test/java/com/microsoft/playwright/TestInstall.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
import com.microsoft.playwright.impl.Driver;
2020
import com.microsoft.playwright.impl.DriverJar;
21-
import org.junit.jupiter.api.*;
21+
import org.junit.jupiter.api.BeforeEach;
22+
import org.junit.jupiter.api.Test;
2223
import org.junit.jupiter.api.io.TempDir;
2324

2425
import java.io.IOException;
26+
import java.lang.reflect.Field;
27+
import java.net.MalformedURLException;
2528
import java.net.ServerSocket;
2629
import java.nio.file.Files;
2730
import java.nio.file.Path;
@@ -30,10 +33,7 @@
3033
import java.util.Map;
3134
import java.util.concurrent.TimeUnit;
3235

33-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
34-
import static org.junit.jupiter.api.Assertions.assertEquals;
35-
import static org.junit.jupiter.api.Assertions.assertThrows;
36-
import static org.junit.jupiter.api.Assertions.assertTrue;
36+
import static org.junit.jupiter.api.Assertions.*;
3737

3838
public class TestInstall {
3939
private static boolean isPortAvailable(int port) {
@@ -63,8 +63,7 @@ void clearSystemProperties() {
6363
}
6464

6565
@Test
66-
@Tags({@Tag("isolated"), @Tag("driverThrowTest")})
67-
void shouldThrowWhenBrowserPathIsInvalid(@TempDir Path tmpDir) {
66+
void shouldThrowWhenBrowserPathIsInvalid(@TempDir Path tmpDir) throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException {
6867
Map<String,String> env = new HashMap<>();
6968

7069
// On macOS we can only use 127.0.0.1, so pick unused port instead.
@@ -74,8 +73,19 @@ void shouldThrowWhenBrowserPathIsInvalid(@TempDir Path tmpDir) {
7473
env.put("PLAYWRIGHT_BROWSERS_PATH", tmpDir.toString());
7574
env.put("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", "false");
7675

77-
assertThrows(RuntimeException.class, () -> Driver.ensureDriverInstalled(env, true));
78-
assertThrows(RuntimeException.class, () -> Driver.ensureDriverInstalled(env, true));
76+
// Reset instance field value to null for the test.
77+
Field field = Driver.class.getDeclaredField("instance");
78+
field.setAccessible(true);
79+
Object value = field.get(Driver.class);
80+
field.set(Driver.class, null);
81+
82+
for (int i = 0; i < 2; i++){
83+
RuntimeException exception = assertThrows(RuntimeException.class, () -> Driver.ensureDriverInstalled(env, true));
84+
String message = exception.getMessage();
85+
assertTrue(message.contains("Failed to create driver"), message);
86+
}
87+
88+
field.set(Driver.class, value);
7989
}
8090

8191
@Test

0 commit comments

Comments
 (0)