Example test automation framework using Gradle,SerenityBDD and JAVA
- To automate against web based applications
- To validate functionality across web based applications
- JAVA should be installed on host platform and JAVA_HOME environment variable must be set host platform.
- Chrome or Chromium browser must be installed and available on host machine.
- Create directory for project if running on local instance
git clone https://github.com/mtboypbtwoyf/serenitybdd.webapplication.tesco.example.git
- Open command line or terminal and navigate to the directory project is cloned to
- Run:
./gradlew clean clearReports test aggregate
orgradle clean clearReports test aggregate
if you already have a gradle installation on host platform. - Test reports are located at
<project-root-folder>/target/site/serenity/index.html
. Test reports can be viewed with any browser of choice.
- If gradle is already installed and configured on host platform/server, invoke the
gradle
command instead of./gradlew
. ./gradlew
indicates you are using a gradle wrapper. The Gradle Wrapper is generally part of a project and it facilitates installation and setup of gradle. If you were using gradle without the wrapper you would have to manually install it - for example, on a mac brew install gradle and then invoke gradle using thegradle
command. In both cases you are using gradle, but the former is more convenient and ensures version consistency across different platforms.- Chrome WebDriver binaries is configured to download automatically using the latest binary version from google chrome api at runtime. This will be consequently cached by the gradle daemon at first build execution to enable faster build execution setup time against future project builds. Please refer to the
CustomChromeDriver.java
class containing the line below for binary setup.
WebDriverManager.chromedriver().version("2.37").setup();
- Tests can be executed using an IDE by right clicking the corresponding feature file and selecting the run feature option. To add and run multiple tests or the complete test suite within an IDE right click and run the
RunTests
class located at the root of the corresponding project package. - Tests can also be executed by running the corresponding command as mentioned in the Quick Start section above.
- To execute tests with using command line arguments, please refer to further documentation provided Gradle Command Line or Serenity Command Line. Some examples are provided below:
./gradlew clean clearReports test aggregate -Dcucumber.options="--tags <cucumber-tag>"
./gradlew clean clearReports test aggregate -Dcucumber.options="--tags @smoke"
./gradlew clean clearReports test aggregate -Dcucumber.options="--tags @login" -Dwebdriver.remote.driver=chrome -Dwebdriver.remote.os=WINDOWS
- Running behind a proxy server? Please refer to the
gradle.properties
file for notes and example config options. Or pass the command line argument at runtime./gradlew -Dhttps.proxyHost=<proxy-server> -Dhttps.proxyPort=<port-number> clean clearReports test aggregate
© 2018 mtboypbtwoyf