You are viewing a plain text version of this content. The canonical link for it is here.
Posted to geb-notifications@groovy.apache.org by jo...@apache.org on 2026/10/08 21:34:20 UTC
(groovy-geb) 03/03: Add JUnit 5 Geb example
This is an automated email from the ASF dual-hosted git repository.
jonnybot0 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy-geb.git
commit b51f4e7cea85fb0fd322d5444cfe4413506a5f8b
Author: copilot-swe-agent[bot] <19...@users.noreply.github.com>
AuthorDate: Fri Oct 2 18:55:30 2026 +0000
Add JUnit 5 Geb example
Co-authored-by: jonnybot0 <37...@users.noreply.github.com>
---
.github/workflows/junit5-example.yml | 35 +++++++++++++++++++
RELEASING.md | 2 +-
geb-examples/geb-junit5/README.md | 26 ++++++++++++++
geb-examples/geb-junit5/geb-junit5.gradle | 40 ++++++++++++++++++++++
.../src/test/groovy/GebishOrgHomePage.groovy | 28 +++++++++++++++
.../src/test/groovy/GebishOrgTest.groovy | 36 +++++++++++++++++++
.../src/test/groovy/ManualsMenuModule.groovy | 33 ++++++++++++++++++
.../src/test/groovy/TheBookOfGebPage.groovy | 24 +++++++++++++
.../geb-junit5/src/test/resources/GebConfig.groovy | 32 +++++++++++++++++
settings.gradle | 1 +
10 files changed, 256 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/junit5-example.yml b/.github/workflows/junit5-example.yml
new file mode 100644
index 00000000..6aaee559
--- /dev/null
+++ b/.github/workflows/junit5-example.yml
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Test JUnit 5 example
+
+on: [push, pull_request]
+
+permissions:
+ contents: read
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6
+ with:
+ distribution: 'zulu'
+ java-version: 17
+ - uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb
+ - run: ./gradlew --no-daemon :geb-examples:geb-junit5:check
diff --git a/RELEASING.md b/RELEASING.md
index 21d5b674..a75510b3 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -64,7 +64,7 @@ limitations under the License.
4. Commit with message 'Begin version «version»'
5. Push (make sure you push the tag as well).
6. Merge the release branch back into the master branch.
-6. Bump the Geb version in the `geb-examples/geb-gradle/geb-gradle.gradle` and `geb-examples/geb-maven/pom.xml` examples, then verify both examples with their CI workflows.
+6. Bump the Geb version in `geb-examples/geb-gradle/geb-gradle.gradle`, `geb-examples/geb-junit5/geb-junit5.gradle`, and `geb-examples/geb-maven/pom.xml`, then verify the examples with their CI workflows.
7. Update issues and milestones in GitHub tracker:
* Find all unresolved issues in the tracker that have the fix version set to the recently released version and bulk edit them to have the fix version set to the next version.
* Find the recently released milestone, change the version number if it's different from the one that was released and close it.
diff --git a/geb-examples/geb-junit5/README.md b/geb-examples/geb-junit5/README.md
new file mode 100644
index 00000000..7b57d21a
--- /dev/null
+++ b/geb-examples/geb-junit5/README.md
@@ -0,0 +1,26 @@
+<!--
+SPDX-License-Identifier: Apache-2.0
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+# Geb JUnit 5 example
+
+This example uses JUnit 5, Selenium Chrome, and Geb in the main Gradle build.
+
+Run it from the repository root:
+
+```shell
+./gradlew :geb-examples:geb-junit5:check
+```
+
+It uses a headless Chrome browser and the [Geb home page](https://groovy.apache.org/geb/).
diff --git a/geb-examples/geb-junit5/geb-junit5.gradle b/geb-examples/geb-junit5/geb-junit5.gradle
new file mode 100644
index 00000000..b9d57bc5
--- /dev/null
+++ b/geb-examples/geb-junit5/geb-junit5.gradle
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+plugins {
+ id 'groovy'
+}
+
+def gebVersion = '8.0.1'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ testImplementation "org.apache.groovy.geb:geb-junit5:$gebVersion"
+ testImplementation 'org.seleniumhq.selenium:selenium-chrome-driver:4.49.0'
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.12.0'
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.12.0'
+}
+
+tasks.withType(Test).configureEach {
+ useJUnitPlatform()
+ systemProperty 'geb.build.reportsDir', reporting.file('geb')
+ systemProperty 'geb.env', 'chromeHeadless'
+}
diff --git a/geb-examples/geb-junit5/src/test/groovy/GebishOrgHomePage.groovy b/geb-examples/geb-junit5/src/test/groovy/GebishOrgHomePage.groovy
new file mode 100644
index 00000000..e4048600
--- /dev/null
+++ b/geb-examples/geb-junit5/src/test/groovy/GebishOrgHomePage.groovy
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import geb.Page
+
+class GebishOrgHomePage extends Page {
+
+ static at = { title == 'Geb - Very Groovy Browser Automation' }
+
+ static content = {
+ manualsMenu { module(ManualsMenuModule) }
+ }
+}
diff --git a/geb-examples/geb-junit5/src/test/groovy/GebishOrgTest.groovy b/geb-examples/geb-junit5/src/test/groovy/GebishOrgTest.groovy
new file mode 100644
index 00000000..e9af4d9e
--- /dev/null
+++ b/geb-examples/geb-junit5/src/test/groovy/GebishOrgTest.groovy
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import geb.junit5.GebReportingTest
+import org.junit.jupiter.api.Test
+
+class GebishOrgTest extends GebReportingTest {
+
+ @Test
+ void canGetToTheCurrentBookOfGeb() {
+ to GebishOrgHomePage
+
+ manualsMenu.open()
+
+ assert manualsMenu.links[0].text().startsWith('current')
+
+ manualsMenu.links[0].click()
+
+ at TheBookOfGebPage
+ }
+}
diff --git a/geb-examples/geb-junit5/src/test/groovy/ManualsMenuModule.groovy b/geb-examples/geb-junit5/src/test/groovy/ManualsMenuModule.groovy
new file mode 100644
index 00000000..3721c4da
--- /dev/null
+++ b/geb-examples/geb-junit5/src/test/groovy/ManualsMenuModule.groovy
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import geb.Module
+
+class ManualsMenuModule extends Module {
+
+ static content = {
+ toggle { $('div.menu a.manuals') }
+ linksContainer { $('#manuals-menu') }
+ links { linksContainer.find('a') }
+ }
+
+ void open() {
+ toggle.click()
+ waitFor { !linksContainer.hasClass('animating') }
+ }
+}
diff --git a/geb-examples/geb-junit5/src/test/groovy/TheBookOfGebPage.groovy b/geb-examples/geb-junit5/src/test/groovy/TheBookOfGebPage.groovy
new file mode 100644
index 00000000..285354f6
--- /dev/null
+++ b/geb-examples/geb-junit5/src/test/groovy/TheBookOfGebPage.groovy
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import geb.Page
+
+class TheBookOfGebPage extends Page {
+
+ static at = { title.startsWith('The Book Of Geb') }
+}
diff --git a/geb-examples/geb-junit5/src/test/resources/GebConfig.groovy b/geb-examples/geb-junit5/src/test/resources/GebConfig.groovy
new file mode 100644
index 00000000..2374db1f
--- /dev/null
+++ b/geb-examples/geb-junit5/src/test/resources/GebConfig.groovy
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import org.openqa.selenium.chrome.ChromeDriver
+import org.openqa.selenium.chrome.ChromeOptions
+
+environments {
+ chromeHeadless {
+ driver = {
+ def options = new ChromeOptions()
+ options.addArguments('--headless=new')
+ new ChromeDriver(options)
+ }
+ }
+}
+
+baseUrl = 'https://groovy.apache.org/geb/'
diff --git a/settings.gradle b/settings.gradle
index 2d6e9eab..19fbf495 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -52,6 +52,7 @@ include "module",
"integration:geb-gradle",
"integration:geb-testcontainers",
"geb-examples:geb-gradle",
+ "geb-examples:geb-junit5",
"doc:asciidoctor-extension",
"doc:manual",
"doc:manual-snippets",