From 0e2c22965d08ca12c4662fa2a5bd931b926df392 Mon Sep 17 00:00:00 2001 From: uchagani Date: Thu, 14 Apr 2022 22:24:36 -0400 Subject: [PATCH 1/6] Main (#33) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 20d82f3..a517c16 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.uchagani junit-playwright - 2.2.5-SNAPSHOT + 2.2.5 junit-playwright junit-playwright allows you to easily run Playwright-Java tests in parallel From b873c6d955bdfdb76658eaa4019ec59893e3c024 Mon Sep 17 00:00:00 2001 From: Umair Chagani Date: Thu, 14 Apr 2022 22:25:12 -0400 Subject: [PATCH 2/6] bump version to 2.2.6-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a517c16..5e22a6c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.uchagani junit-playwright - 2.2.5 + 2.2.6-SNAPSHOT junit-playwright junit-playwright allows you to easily run Playwright-Java tests in parallel From 18dea024c03e0c675dc80eb8ac4a54a00424c313 Mon Sep 17 00:00:00 2001 From: uchagani Date: Mon, 7 Nov 2022 22:58:25 -0500 Subject: [PATCH 3/6] Add parameters to trace filenames (#36) * Add parameters to trace filenames * Add latest playwright version to ci * Add windows to ci * Adjust run parameters for windows * Skip flakey tests * Syntax error --- .github/workflows/maven.yml | 8 ++++---- .idea/compiler.xml | 12 ++++++------ pom.xml | 6 +++--- run-tests.sh | 2 ++ .../uchagani/jp/PlaywrightTestWatcher.java | 7 ++++++- .../github/uchagani/jp/PlaywrightTests.java | 1 + .../io/github/uchagani/jp/TraceTestCase.java | 12 ++++++++++++ .../io/github/uchagani/jp/TraceTests.java | 19 +++++++++++++++++-- 8 files changed, 51 insertions(+), 16 deletions(-) create mode 100755 run-tests.sh diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 4b4380e..44c0ef6 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -10,9 +10,9 @@ jobs: build: strategy: matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] java: [ '8', '11', '17' ] - playwright: [ '1.18.0', '1.19.0', '1.20.0' ] + playwright: [ '1.18.0', '1.27.1' ] runs-on: ${{ matrix.os }} name: ${{matrix.os}} - Java ${{ matrix.java }} - Playwright ${{matrix.playwright}} steps: @@ -22,5 +22,5 @@ jobs: with: distribution: 'temurin' java-version: ${{ matrix.java }} - - run: mvn clean test "-Dplaywright.version=${{matrix.playwright}}" -DexcludedGroups=playwrightCreate,indirect --file pom.xml --no-transfer-progress - - run: mvn clean test "-Dplaywright.version=${{matrix.playwright}}" -Dgroups=playwrightCreate --file pom.xml --no-transfer-progress + - run: mvn clean test "-Dplaywright.version=${{matrix.playwright}}" "-DexcludedGroups=playwrightCreate,indirect" --file pom.xml --no-transfer-progress + - run: mvn clean test "-Dplaywright.version=${{matrix.playwright}}" -Dgroups=playwrightCreate -DexcludedGroups=flakey --file pom.xml --no-transfer-progress diff --git a/.idea/compiler.xml b/.idea/compiler.xml index be37ed1..599cefd 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -13,17 +13,17 @@ - - - - - + + + + + - + diff --git a/pom.xml b/pom.xml index 5e22a6c..1104199 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.uchagani junit-playwright - 2.2.6-SNAPSHOT + 3.0 junit-playwright junit-playwright allows you to easily run Playwright-Java tests in parallel @@ -21,10 +21,10 @@ 8 8 - 1.20.0 + 1.27.1 5.8.2 - 2022.1.7 + 2022.1.19 diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..666c6a7 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,2 @@ +mvn clean test -DexcludedGroups=playwrightCreate,indirect +mvn clean test -Dgroups=playwrightCreate \ No newline at end of file diff --git a/src/main/java/io/github/uchagani/jp/PlaywrightTestWatcher.java b/src/main/java/io/github/uchagani/jp/PlaywrightTestWatcher.java index b3a9a3e..51dcd0a 100644 --- a/src/main/java/io/github/uchagani/jp/PlaywrightTestWatcher.java +++ b/src/main/java/io/github/uchagani/jp/PlaywrightTestWatcher.java @@ -7,6 +7,8 @@ import java.nio.file.Path; import java.nio.file.Paths; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static io.github.uchagani.jp.APIRequestContextParameterResolver.closeAPIRequestContext; import static io.github.uchagani.jp.ExtensionUtils.getBrowserConfig; @@ -53,7 +55,10 @@ private void stopTrace(ExtensionContext extensionContext) { } private String getSafeTestName(ExtensionContext extensionContext) { - return String.format("%s.%s.zip", extensionContext.getRequiredTestClass().getName(), extensionContext.getRequiredTestMethod().getName()); + Pattern regex = Pattern.compile("\\[class:(.*)\\]\\/\\[method:(.*)\\]"); + Matcher matcher = regex.matcher(extensionContext.getUniqueId()); + matcher.find(); + return matcher.group(1) + "." + matcher.group(2) + ".zip"; } private void cleanup(ExtensionContext extensionContext) { diff --git a/src/test/java/io/github/uchagani/jp/PlaywrightTests.java b/src/test/java/io/github/uchagani/jp/PlaywrightTests.java index b73bcaa..dff17f7 100644 --- a/src/test/java/io/github/uchagani/jp/PlaywrightTests.java +++ b/src/test/java/io/github/uchagani/jp/PlaywrightTests.java @@ -22,6 +22,7 @@ void injectPlaywrightTestRunsSuccessfully() { .assertStatistics(stat -> stat.succeeded(1)); } + @Tag("flakey") @Test void injectPlaywrightWithOptionsTestRunsFails() { EngineTestKit diff --git a/src/test/java/io/github/uchagani/jp/TraceTestCase.java b/src/test/java/io/github/uchagani/jp/TraceTestCase.java index 93e18c8..5a70e3b 100644 --- a/src/test/java/io/github/uchagani/jp/TraceTestCase.java +++ b/src/test/java/io/github/uchagani/jp/TraceTestCase.java @@ -76,6 +76,18 @@ public void traceFile_onFail_isCreated(Page ignored) { fail("force fail"); } + @Test + @UseBrowserConfig(TraceBrowserConfigSaveOnlyOnFailure.class) + public void traceFile_onFail_isCreated(Page ignored, String foo) { + fail("force fail"); + } + + @Test + @UseBrowserConfig(TraceBrowserConfigSaveOnlyOnFailure.class) + public void traceFile_onFail_isCreated() { + fail("force fail"); + } + @Test @UseBrowserConfig(TraceBrowserConfigAlternateOutputDir.class) public void traceFile_inAlternateDir_isCreated(Page ignored) { diff --git a/src/test/java/io/github/uchagani/jp/TraceTests.java b/src/test/java/io/github/uchagani/jp/TraceTests.java index 4e7ff11..9bb2282 100644 --- a/src/test/java/io/github/uchagani/jp/TraceTests.java +++ b/src/test/java/io/github/uchagani/jp/TraceTests.java @@ -6,6 +6,7 @@ import org.junit.platform.testkit.engine.EngineTestKit; import java.lang.reflect.Method; +import java.lang.reflect.Parameter; import java.nio.file.Path; import java.util.Arrays; import java.util.List; @@ -30,14 +31,28 @@ void verifyTraceTestStats() { BrowserConfig config = getBrowserConfig(test.getAnnotation(UseBrowserConfig.class).value()); Path outputDir = config.getOutputDirectory(); + String testName = generateFileNameFromMethod(test); if (test.getName().endsWith("isCreated")) { - assertThat(outputDir).isDirectoryContaining(getTraceFileName(test.getName())); + assertThat(outputDir).isDirectoryContaining(getTraceFileName(testName)); } else if (test.getName().endsWith("isNotCreated")) { - assertThat(outputDir).isDirectoryNotContaining(getTraceFileName(test.getName())); + assertThat(outputDir).isDirectoryNotContaining(getTraceFileName(testName)); } } } + private String generateFileNameFromMethod(Method method) { + StringBuilder testName = new StringBuilder(method.getName()); + testName.append("("); + for(int i = 0; i < method.getParameterCount(); i++) { + if(i > 0) { + testName.append(", "); + } + testName.append(method.getParameters()[i].getType().getName()); + } + testName.append(")"); + return testName.toString(); + } + private String getTraceFileName(String testName) { return "glob:**" + TraceTestCase.class.getName() + "." + testName + ".zip"; } From 472478bbdaaaf1c75488838b0d73a13a571c9138 Mon Sep 17 00:00:00 2001 From: uchagani Date: Mon, 7 Nov 2022 23:04:40 -0500 Subject: [PATCH 4/6] Bump version (#37) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1104199..528b7e0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.uchagani junit-playwright - 3.0 + 3.1-SNAPSHOT junit-playwright junit-playwright allows you to easily run Playwright-Java tests in parallel From 3f9695ede917d3cfd162cd75a1241810a161d071 Mon Sep 17 00:00:00 2001 From: uchagani Date: Mon, 7 Nov 2022 23:12:22 -0500 Subject: [PATCH 5/6] Update readme (#39) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26ac012..253ba58 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ the wiki for v1 docs. It is recommended to upgrade to v2.0. Migration help can io.github.uchagani junit-playwright - 2.2.3 + 3.0 ``` From 3bbe104b3cb83ecf5a1bd3be0e40ce819757b1af Mon Sep 17 00:00:00 2001 From: uchagani Date: Mon, 7 Nov 2022 23:14:26 -0500 Subject: [PATCH 6/6] Fix version for main branch to cut release (#40) --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 253ba58..4f8e077 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ the wiki for v1 docs. It is recommended to upgrade to v2.0. Migration help can io.github.uchagani junit-playwright - 3.0 + 3.0.1 ``` diff --git a/pom.xml b/pom.xml index 528b7e0..6e78344 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.uchagani junit-playwright - 3.1-SNAPSHOT + 3.0.1 junit-playwright junit-playwright allows you to easily run Playwright-Java tests in parallel