This project is a boilerplate for mobile application automation testing. It uses Java as the programming language, Cucumber for behavior-driven development (BDD), and Appium for mobile application testing.
- Prerequisites
- Setup
- Project Tree and Functions of Branches
- Running Tests
- Run Tests with Specific Platform
- Run Tests with Specific Capability
- Run Tests with Specific Tag
- Allure Reporting
- Java Development Kit (JDK) 8 or above
- Maven
- Appium
- Cucumber
- An Android or iOS Emulator/Simulator or real device
- IDE (IntelliJ IDEA, Eclipse, etc.)
-
Clone the repository:
https://github.com/kloia/mobile-automation-testing-appium-java.git
-
Navigate to the project directory:
cd mobile-automation-testing-appium-java
-
Install dependencies:
mvn install
-
Edit Test Capabilities:
Open
DigitalAIConfig
and modify theDesiredCapabilities
according to your test device and application.
.gitignore 📍Config file with list of unwanted files and folders in Git repository
README.md 📍It is a text file that contains the purpose, usage and other basic information of the project
pom.xml 📍Management of the libraries to be used in the project
src
|-- test
| |-- java
| | |-- configs.DigitalAIConfigs
| | | |-- Android.properties 📍Configuration file for Android platform capabilities.
| | | |-- DigitalAIConfig.java
| | | |-- IOS.properties 📍Configuration file for IOS platform capabilities.
| | |-- test
| | | |-- features 📍Cucumber feature file defining test scenarios.
| | | | |-- Login.feature
| | | | |-- ProductListing.feature
| | | |-- runners
| | | | |-- TestRunner.java 📍TestNG test runner class with Cucumber options, setting up test execution, and providing data-driven scenarios.
| | | |-- stepDefinations
| | | | |-- Hooks.java 📍Hooks class with setup and teardown methods using TestNG annotations for managing Appium driver instances.
| | | | |-- LoginSteps.java
| | | | |-- ProductListingSteps.java
| | | |- - pages
| | | | |-- LoginPage.java
| | | | |-- ProductListingPage.java
| | |-- utilities
| | | |-- PageHelper.java 📍Helper class for common actions and methods used in page classes.
| | | |-- ConfReader.java 📍Configuration reader class for reading properties files.
| | | |-- DesiredCapabilitiesUtil.java 📍Utility class for creating Appium DesiredCapabilities based on the configuration.
| | | |-- ThreadLocalDriver.java 📍Thread-safe singleton class for managing the Appium driver instance.
testng.xml 📍TestNG is an XML file that contains configuration settings (test suites, test methods, parameters, groups, etc.) for the testing framework.
To run tests, you can either run them through your IDE or via the command line.
-
Command Line:
mvn test
-
IntelliJ IDEA:
Right-click on the test directory and choose "Run 'All Tests'".
The project is configured to support both iOS and Android platforms. Make sure to choose the appropriate configuration for your tests. Use the following commands in the terminal to run tests on Android or iOS devices:
Android: mvn test -Dplatform=Android
iOS: mvn test -Dplatform=IOS
To change a specific capability value, use the following command in the terminal:
mvn test -DtestName=mobile test
Replace testName with the desired capability key, and mobile with the new value.
To change a specific tag, use the following command in the terminal:
mvn test -Dtags="@login"
Replace the @login tag with the tag you want
The project is configured to support both local and remote environments. Make sure to choose the appropriate configuration for your tests. To run tests in a local or remote environment, use the following commands in the terminal:
Local: mvn test -Denvironment=Local
Remote: mvn test -Denvironment=DigitalAI
After the test execution, Allure reports are generated in the target/allure-results directory. Use the Allure command mentioned below to view the reports.
allure serve target/allure-results