diff --git a/docs/src/test-runners-java.md b/docs/src/test-runners-java.md index 9daf09cf0f..05850b3460 100644 --- a/docs/src/test-runners-java.md +++ b/docs/src/test-runners-java.md @@ -186,3 +186,95 @@ junit.jupiter.execution.parallel.mode.classes.default = concurrent junit.jupiter.execution.parallel.config.strategy=dynamic junit.jupiter.execution.parallel.config.dynamic.factor=0.5 ``` + +### Using Gradle + +You can use a Gradle build configuration script, written in Groovy or Kotlin. + + + + +```java +plugins { + application + id 'java' +} + +repositories { + mavenCentral() +} + +dependencies { + implementation 'com.microsoft.playwright:playwright:%%VERSION%%' +} + +application { + mainClass = 'org.example.App' +} + +// Usage: ./gradlew playwright --args="help" +task playwright(type: JavaExec) { + classpath sourceSets.test.runtimeClasspath + mainClass = 'com.microsoft.playwright.CLI' +} + +test { + useJUnitPlatform() +} +``` + + + + +```java +plugins { + application + id("java") +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("com.microsoft.playwright:playwright:%%VERSION%%") +} + +application { + mainClass.set("org.example.App") +} + +// Usage: ./gradlew playwright --args="help" +tasks.register("playwright") { + classpath(sourceSets["test"].runtimeClasspath) + mainClass.set("com.microsoft.playwright.CLI") +} + +tasks.test { + useJUnitPlatform() + testLogging { + events("passed", "skipped", "failed") + } +} +``` + + + + +Tests can then be launched as follows: + +```bash +./gradlew run +``` + +Also, Playwright command line tools can be run with : + +```bash +./gradlew playwright --args="help" +```