Screen.Recording.2024-08-18.at.6.16.56.AM.mp4
This project is a Java test automation framework made using Appium, Cucumber, and JUnit. It uses the Page Object Model (POM) design pattern for better test maintainability and readability.
For parallel testing capabilities, this repo leverages the help of CourgetteJVM library and Appium Device Farm plugin for the Appium Server running separately.
This repo also has a DockerFile for setting up JDK 17 and Allure reporter which you can run your tests from.
The scenarios on Example.feature file uses WebdriverIO's sample app. The app's download location
will be used for the APP_PATH
environment variable located in the .env file
For now only runs Android automation tests (iOS is planned for later).
Before setting up the project, ensure you have the following installed:
- Node.js (Required for Appium)
- Appium
- UiAutomator2 driver
appium driver install uiautomator2
- Device Farm plugin (To support parallel device assignment)
appium plugin install --source=npm appium-device-farm
- UiAutomator2 driver
- Android SDK (For Android testing)
- Set up
ANDROID_HOME
environment variable to point to the directory where the Android SDK is installed.
- Set up
- Java JDK 17 or higher
- Set up
JAVA_HOME
environment variable to point to the JDK home directory
- Set up
- Allure Reporter
- Bash shell
The project is structured as follows:
Parallel Automation
├── README.md # README file
├── LICENSE # License file
├── .env # Environment variables (make your own locally)
├── .env.example # Environment variables template
├── build.gradle # Build script for this Gradle project
├── run_test.sh # Bash script to run test and generate report
├── build
│ ├── allure-results/ # Raw report data
│ ├── allure-report/ # Final HTML report
│ └── cucumber.json # Cucumber JSON file
│
└── src
└── test
├── java
│ │
│ ├── page_objects
│ │ ├── BasePage.java # Abstract class containing common page methods
│ │ ├── pages/ # Contains page objects
│ │ └── fragments/ # Contains page objects for smaller elements like widgets, components, etc.
│ │
│ ├── step_definitions/ # Contains Cucumber step definitions
│ │
│ └── utils
│ ├── Constants.java # List of fixed constants
│ ├── Helpers.java # List of helper methods
│ ├── drivers/ # Contains Appium Drivers
│ ├── hooks/ # Contains Cucumber Hooks
│ └── runners/ # Contains Cucumber Test Runners
│
└── resources/
├── allure.properties # Allure configs
├── .test_data # Test data (make your own locally)
├── .test_data.example # Test data template
└── features/ # Contains Cucumber feature files
- Clone the Repository:
git clone https://github.com/your-username/your-repo-name.git cd your-repo-name
- Wait for gradle to install its dependencies.
- Appium setup:
- Run Appium server with the proper plugins and flags as follows:
appium server -pa /wd/hub/ --use-plugins=device-farm --plugin-device-farm-platform=android
- Run Appium server with the proper plugins and flags as follows:
- Environment and Test Data variables setup.
- There are 2 files named
.env.example
and.test_data.example
(located insrc/test/resources/
) - Base both of your
.env
and.test_data
files from here. - Setting values:
APP_PATH=<path of your local app> APPIUM_URL=<Make sure to use the non-localhost Appium URL!>
- There are 2 files named
- If you're using Docker, follow the Docker setup steps after this.
- Turn on Docker Engine.
- Open terminal, go to the root of your project
- Build the docker image from the DockerFile by running:
docker build -t <name_of_your_image> .
- After the image is built, run:
This will mount our working directory as a volume inside our Docker container with all proper dependencies installed.
docker run -v $(pwd):/app -it --rm <name_of_your_image>
To run the test on 1 parallel thread, run:
bash run_test.sh
To run the test on multiple parallel threads, run:
bash run_test.sh <NUMBER_OF_THREADS>
You can also set the number of threads in src/test/java/utils/runners/CourgetteRunner.java
.
After test execution, you can find the reports in the build/
folder. Allure reports and cucumber.json
file are
stored here.
Distributed under the MIT License. See LICENSE for more information.
© Bryan Ramaputra Purnama (2024). All rights reserved.