Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
uchagani committed Nov 8, 2022
2 parents f9cc42f + 3bbe104 commit 764b532
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
12 changes: 6 additions & 6 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ the wiki for v1 docs. It is recommended to upgrade to v2.0. Migration help can
<dependency>
<groupId>io.github.uchagani</groupId>
<artifactId>junit-playwright</artifactId>
<version>2.2.3</version>
<version>3.0.1</version>
</dependency>
```

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.uchagani</groupId>
<artifactId>junit-playwright</artifactId>
<version>2.2.5</version>
<version>3.0.1</version>

<name>junit-playwright</name>
<description>junit-playwright allows you to easily run Playwright-Java tests in parallel</description>
Expand All @@ -21,10 +21,10 @@
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<playwright.version>1.20.0</playwright.version>
<playwright.version>1.27.1</playwright.version>
<junit.version>5.8.2</junit.version>
<!-- set latest manifold version here -->
<manifold.version>2022.1.7</manifold.version>
<manifold.version>2022.1.19</manifold.version>
</properties>

<scm>
Expand Down
2 changes: 2 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mvn clean test -DexcludedGroups=playwrightCreate,indirect
mvn clean test -Dgroups=playwrightCreate
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/github/uchagani/jp/PlaywrightTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void injectPlaywrightTestRunsSuccessfully() {
.assertStatistics(stat -> stat.succeeded(1));
}

@Tag("flakey")
@Test
void injectPlaywrightWithOptionsTestRunsFails() {
EngineTestKit
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/io/github/uchagani/jp/TraceTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 17 additions & 2 deletions src/test/java/io/github/uchagani/jp/TraceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
}
Expand Down

0 comments on commit 764b532

Please sign in to comment.