End-to-end tests with Spock, Geb and Unirest (e2e-spock-geb)
spock, geb and unirest e2e testing quickstarter project
What files / architecture is generated?
. ├── Jenkinsfile ├── .pre-commit-config.yaml ├── README.md ├── sonar-project.properties ├── src │ ├── test │ │ └── acceptance │ │ │ └── groovy │ │ │ │ └── DemoAcceptanceSpec.groovy │ │ │ └── java │ │ │ └── DemoAcceptanceTest.java │ │ └── installation │ │ │ └── groovy │ │ │ │ └── DemoInstallationSpec.groovy │ │ │ └── java │ │ │ └── DemoInstallationTest.java │ │ └── integration │ │ │ └── groovy │ │ │ │ └── DemoIntegrationSpec.groovy │ │ │ └── java │ │ | └── DemoIntegrationTest.java │ │ └── resources │ │ └── application.properties │ │ └── GebConfig.groovy │ │ └── SpecHelper.groovy ├── gradle │ └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── build.gradle ├── gradlew └── gradlew.bat
Gradle Support
The generated project includes a gradlew wrapper which is a portable distribution of gradle. It allows you to easily build the project without any further tool installation other than java.
Gradle Artifacts
You´ll find in the project following gradle artifacts:
-
build.gradle
(build definition) -
gradlew.bat
-
gradlew
-
gradle/wrapper/gradle-wrapper.jar
-
gradle/wrapper/gradle.properties
gradle.properties is missing. This is on purpose, because you need to define it on your own by providing your nexus configuration. |
Nexus configuration in gradle.properties
You´ll need to create gradle.properties
yourself and add following properties:
nexus_url=<URL_OF_YOUR_NEXUS_SERVER>
nexus_user=<YOUR_NEXUS_USERNAME>
nexus_pw=<YOUR_NEXUS_PASSWORD>
If you do not want to use Nexus at all, just define the following property:
no_nexus=true
Run gradlew -v
to verify the installed version of gradle wrapper.
Usage - how do you start after you provisioned this quickstarter
-
Run command
gradlew test
in project directory to execute the end-to-end tests via spock/geb against the Google Home page and demo jUnit 5 tests.
You will see the results inside a new folder 'build' in project directory.
. └── build └── test-results ├── acceptance-groovy │ └── TEST-DemoAcceptance.xml ├── acceptance-java │ └── TEST-DemoAcceptanceTest.xml ├── installation-groovy │ └── TEST-DemoInstallation.xml ├── installation-java │ └── TEST-DemoInstallationTest.xml ├── integration-groovy │ └── TEST-DemoIntegration.xml └── integration-java └── TEST-DemoIntegrationTest.xml
Customization - how do you start to configure your test
-
You can see how a Java Junit 5 test are developed showing the Demo*Test.java files.
-
You can see how a Groovy Spock/Geb test are developed showing the Demo*Spec.groovy files.
-
The url to test with Geb is configured in the property
config.application.url
insideapplication.properties
-
Inside
GebConfig.groovy
you could change the default navigator (CHROME)
-
How this quickstarter is built through jenkins
The Jenkinsfile is provisioned with this quickstarter to ease CI/CD process. In Jenkinsfile.template, there is the following stage:
-
stageTest - Run the programed e2e test with this order:
-
installation-java
-
installation-groovy
-
integration-java
-
integration-groovy
-
acceptance-java
-
acceptance-groovy
-
All the results are stashed and published through Jenkins jUnit publisher.
include::partial$secret-scanning-with-gitleaks.adoc
Builder agent used
This quickstarter uses the jdk Jenkins builder agent.