Skip to content

Commit d592176

Browse files
committed
Convert to Gradle focused starter project
1 parent 83aabb5 commit d592176

File tree

26 files changed

+156
-828
lines changed

26 files changed

+156
-828
lines changed

.github/workflows/build.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
name: Cucumber CI
1+
name: Test Java
2+
3+
permissions: { }
24

35
on:
4-
push:
56
pull_request:
67
branches:
78
- main
9+
push:
10+
branches:
11+
- main
12+
- renovate/**
813

914
jobs:
1015
build:
11-
name: 'Build'
12-
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest, windows-latest ]
19+
version: [ 17, 21 ]
20+
name: 'Build Java ${{ matrix.version }} - ${{ matrix.os }}'
21+
runs-on: ${{ matrix.os }}
1322
steps:
1423
- uses: actions/checkout@v6
15-
- name: Cache local Maven repository
16-
uses: actions/cache@v4
17-
with:
18-
path: ~/.m2/repository
19-
key: build-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
20-
restore-keys: |
21-
build-${{ runner.os }}-maven-
22-
- uses:
23-
AdoptOpenJDK/install-jdk@v1
24+
- uses: actions/setup-java@v5
2425
with:
25-
version: '17'
26-
- name: test maven
27-
run: |
28-
cd maven
29-
./mvnw test -Dmaven.test.failure.ignore
30-
- run: grep -q "The step 'I wait 1 hour' and 1 other step(s) are undefined." maven/target/surefire-reports/io.cucumber.skeleton.RunCucumberTest.txt || ( echo "mvn test didn't fail as expected" && false )
31-
- name: test gradle
32-
run: |
33-
cd gradle
34-
./gradlew test || true
35-
- run: grep -q "The step 'I wait 1 hour' and 1 other step(s) are undefined." gradle/build/reports/tests/test/classes/io.cucumber.skeleton.RunCucumberTest.html || ( echo "gradle test didn't fail as expected" && false )
36-
- name: compare gradle and maven sources
37-
run: diff gradle/src maven/src
26+
distribution: 'temurin'
27+
java-version: ${{ matrix.version }}
28+
cache: 'maven'
29+
- name: Gradle Test
30+
run: ./gradlew test

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
# Eclipse IDE
66
.settings
77
.classpath
8-
.project
8+
.project
9+
10+
# Gradle
11+
.gradle
12+
build

README.md

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Cucumber-Java Skeleton
1+
# Cucumber-JVM Starter: Java with Gradle
22

3-
This is the simplest possible setup for Cucumber using Java. There is nothing
4-
fancy like a webapp or browser testing. All this does is to show you how to
5-
set up and run Cucumber!
3+
This is the simplest possible setup for Cucumber using Java with Gralde.
4+
There is nothing fancy like a webapp or browser testing. All this does is to
5+
show you how to set up and run Cucumber!
66

77
There is a single feature file with one scenario. The scenario has three steps,
8-
two of them pending. See if you can make them all pass!
8+
one passing, skipped and undefined. See if you can make them all pass!
99

1010
To write assertions the project comes with [AssertJ](https://assertj.github.io/doc/#assertj-core-assertions-guide)
1111
included.
@@ -14,32 +14,15 @@ included.
1414

1515
Git:
1616

17-
git clone https://github.com/cucumber/cucumber-java-skeleton.git
18-
cd cucumber-java-skeleton
17+
git clone https://github.com/cucumber/cucumber-jvm-starter-gradle-java.git
18+
cd cucumber-jvm-starter-gradle-java
1919

20-
Subversion:
21-
22-
svn checkout https://github.com/cucumber/cucumber-java-skeleton/trunk cucumber-java-skeleton
23-
cd cucumber-java-skeleton
24-
25-
Or [download a zip](https://github.com/cucumber/cucumber-java-skeleton/archive/main.zip) file.
20+
Or [download a zip](https://github.com/cucumber/cucumber-jvm-starter-gradle-java/archive/main.zip) file.
2621

2722
## Run the tests
28-
### Use Maven
2923

3024
Open a command window and run:
3125

32-
cd maven
33-
./mvnw test
34-
35-
This runs Cucumber features using Cucumber's JUnit Platform Engine. The `Suite`
36-
annotation on the `RunCucumberTest` class tells JUnit to kick off Cucumber.
37-
38-
### Use Gradle
39-
40-
Open a command window and run:
41-
42-
cd gradle
4326
./gradlew test --rerun-tasks --info
4427

4528
This runs Cucumber features using Cucumber's JUnit Platform Engine. The `Suite`
@@ -80,31 +63,30 @@ Then add an annotation to `RunCucumberTest`.
8063
@IncludeTags("Zucchini")
8164
```
8265

83-
When using Maven, tags can be selected from the CLI using the `groups` and `excludedGroups` parameters. These take a
66+
These take a
8467
[JUnit5 Tag Expression](https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions).
8568
Note: When using JUnit, the `@` is not part of the tag.
8669

70+
Tags can also be selected from the CLI using the `cucumber.filter.tags` parameter.
71+
This takes a [Cucumber Expression](https://github.com/cucumber/cucumber-expressions).
72+
8773
```
88-
mvn verify -DexcludedGroups="Haricots" -Dgroups="Zucchini | Gherkin"
74+
./gradlew test --rerun-tasks --info -Dcucumber.filter.tags="not @Haricots and (@Zucchini or @Gherkin)"
8975
```
9076

77+
Note: Add `-Dcucumber.plugin=pretty` to get a more detailed output during test execution.
78+
9179
### Running a single scenario or feature
9280

93-
Maven and Gradle do not (yet) support selecting single features or scenarios
81+
Gradle does not (yet) support selecting single features or scenarios
9482
with JUnit selectors. As a work around the `cucumber.features` property can be
9583
used. Because this property will cause Cucumber to ignore any other selectors
9684
from JUnit it is prudent to only execute the Cucumber engine.
9785

98-
#### With Maven
99-
10086
To select the scenario on line 3 of the `belly.feature` file use:
10187

10288
```
103-
./mvnw test -Dsurefire.includeJUnit5Engines=cucumber -Dcucumber.features=src/test/resources/io/cucumber/skeleton/belly.feature:3
89+
./gradlew test --rerun-tasks --info -Dcucumber.features=src/test/resources/io/cucumber/skeleton/belly.feature:3 -Dcucumber.plugin=pretty
10490
```
10591

10692
Note: Add `-Dcucumber.plugin=pretty` to get a more detailed output during test execution.
107-
108-
#### With Gradle
109-
110-
TODO: (I don't know how to do this. Feel free to send a pull request. ;))
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ repositories {
1919
}
2020

2121
tasks.withType<Test> {
22-
useJUnitPlatform()
22+
useJUnitPlatform {
23+
// When running an individual scenario, assume we only want to run
24+
// Cucumber
25+
System.getProperty("cucumber.features")?.let { includeEngines("cucumber") }
26+
}
27+
28+
// Pass selected system properties to Cucumber
29+
System.getProperty("cucumber.features")?.let { systemProperty("cucumber.features", it) }
30+
System.getProperty("cucumber.filter.tags")?.let { systemProperty("cucumber.filter.tags", it) }
31+
System.getProperty("cucumber.filter.name")?.let { systemProperty("cucumber.filter.name", it) }
32+
System.getProperty("cucumber.plugin")?.let { systemProperty("cucumber.plugin", it) }
33+
2334
// Work around. Gradle does not include enough information to disambiguate
2435
// between different examples and scenarios.
2536
systemProperty("cucumber.junit-platform.naming-strategy", "long")

gradle/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

gradle/src/test/resources/junit-platform.properties

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
@rem
2-
@rem Copyright 2015 the original author or authors.
3-
@rem
4-
@rem Licensed under the Apache License, Version 2.0 (the "License");
5-
@rem you may not use this file except in compliance with the License.
6-
@rem You may obtain a copy of the License at
7-
@rem
8-
@rem https://www.apache.org/licenses/LICENSE-2.0
9-
@rem
10-
@rem Unless required by applicable law or agreed to in writing, software
11-
@rem distributed under the License is distributed on an "AS IS" BASIS,
12-
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
@rem See the License for the specific language governing permissions and
14-
@rem limitations under the License.
15-
@rem
16-
@rem SPDX-License-Identifier: Apache-2.0
17-
@rem
18-
19-
@if "%DEBUG%"=="" @echo off
20-
@rem ##########################################################################
21-
@rem
22-
@rem Gradle startup script for Windows
23-
@rem
24-
@rem ##########################################################################
25-
26-
@rem Set local scope for the variables with windows NT shell
27-
if "%OS%"=="Windows_NT" setlocal
28-
29-
set DIRNAME=%~dp0
30-
if "%DIRNAME%"=="" set DIRNAME=.
31-
@rem This is normally unused
32-
set APP_BASE_NAME=%~n0
33-
set APP_HOME=%DIRNAME%
34-
35-
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
36-
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37-
38-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39-
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40-
41-
@rem Find java.exe
42-
if defined JAVA_HOME goto findJavaFromJavaHome
43-
44-
set JAVA_EXE=java.exe
45-
%JAVA_EXE% -version >NUL 2>&1
46-
if %ERRORLEVEL% equ 0 goto execute
47-
48-
echo. 1>&2
49-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50-
echo. 1>&2
51-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52-
echo location of your Java installation. 1>&2
53-
54-
goto fail
55-
56-
:findJavaFromJavaHome
57-
set JAVA_HOME=%JAVA_HOME:"=%
58-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59-
60-
if exist "%JAVA_EXE%" goto execute
61-
62-
echo. 1>&2
63-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64-
echo. 1>&2
65-
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66-
echo location of your Java installation. 1>&2
67-
68-
goto fail
69-
70-
:execute
71-
@rem Setup the command line
72-
73-
74-
75-
@rem Execute Gradle
76-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
77-
78-
:end
79-
@rem End local scope for the variables with windows NT shell
80-
if %ERRORLEVEL% equ 0 goto mainEnd
81-
82-
:fail
83-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
84-
rem the _cmd.exe /c_ return code!
85-
set EXIT_CODE=%ERRORLEVEL%
86-
if %EXIT_CODE% equ 0 set EXIT_CODE=1
87-
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
88-
exit /b %EXIT_CODE%
89-
90-
:mainEnd
91-
if "%OS%"=="Windows_NT" endlocal
92-
93-
:omega
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
18+
19+
@if "%DEBUG%"=="" @echo off
20+
@rem ##########################################################################
21+
@rem
22+
@rem Gradle startup script for Windows
23+
@rem
24+
@rem ##########################################################################
25+
26+
@rem Set local scope for the variables with windows NT shell
27+
if "%OS%"=="Windows_NT" setlocal
28+
29+
set DIRNAME=%~dp0
30+
if "%DIRNAME%"=="" set DIRNAME=.
31+
@rem This is normally unused
32+
set APP_BASE_NAME=%~n0
33+
set APP_HOME=%DIRNAME%
34+
35+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
36+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37+
38+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40+
41+
@rem Find java.exe
42+
if defined JAVA_HOME goto findJavaFromJavaHome
43+
44+
set JAVA_EXE=java.exe
45+
%JAVA_EXE% -version >NUL 2>&1
46+
if %ERRORLEVEL% equ 0 goto execute
47+
48+
echo. 1>&2
49+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50+
echo. 1>&2
51+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52+
echo location of your Java installation. 1>&2
53+
54+
goto fail
55+
56+
:findJavaFromJavaHome
57+
set JAVA_HOME=%JAVA_HOME:"=%
58+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59+
60+
if exist "%JAVA_EXE%" goto execute
61+
62+
echo. 1>&2
63+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64+
echo. 1>&2
65+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66+
echo location of your Java installation. 1>&2
67+
68+
goto fail
69+
70+
:execute
71+
@rem Setup the command line
72+
73+
74+
75+
@rem Execute Gradle
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
77+
78+
:end
79+
@rem End local scope for the variables with windows NT shell
80+
if %ERRORLEVEL% equ 0 goto mainEnd
81+
82+
:fail
83+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
84+
rem the _cmd.exe /c_ return code!
85+
set EXIT_CODE=%ERRORLEVEL%
86+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
87+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
88+
exit /b %EXIT_CODE%
89+
90+
:mainEnd
91+
if "%OS%"=="Windows_NT" endlocal
92+
93+
:omega

0 commit comments

Comments
 (0)