top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Appium End to End project Flow With Cucumber BDD

Apr 29
3 min read
what is an Appium?

Appium is an open-source tool used to test mobile applications. Mobile testing is very important because nowadays people use smartphones for almost everything in their daily life. Tasks like communication, shopping, banking, and entertainment are all done through mobile apps. So, it is important to make sure these apps work correctly, and Appium helps us automate that testing.


What Tools & Technologies used in Appium project?

In this project, the following tools and technologies were used to build an end-to-end mobile automation framework:

  • Appium – Used to automate mobile applications (Android/iOS).

  • Appium Inspector – Helps to inspect elements and identify locators in the mobile app.

  • Android Emulator – Used to simulate a real Android device for testing.

  • Java – Programming language used to write test scripts.

  • Selenium WebDriver – Provides the WebDriver interface which Appium uses for automation.

  • Maven – Used for dependency management and project build.

  • Cucumber – Used for Behavior Driven Development (BDD) to write test scenarios in a readable format.


Framework Design:

In this Appium automation project, I followed a Page Object Model (POM) with Cucumber BDD framework. The project is organized in a modular way to make it easy to maintain and scalable.



Project Structure Explanation:

  

🔹 Pom.XML : pom.xml is the heart of any Maven-based Java project. It manages everything needed to build and run your project in one place.

🔹 Hooks.java : Hooks contains setup and tear down methods. It is used to execute pre-condition and post- condition actions for every scenario.Example: launching the app before test execution and closing the app after execution.


Setting Up the Appium AndroidDriver with UiAutomator2


Before running any automated test on an Android device, you need to configure and initialize the Appium driver. The code below demonstrates how to set up a UiAutomator2Options object with device-specific capabilities — such as device name, platform version, app package, and app activity — all read from an external config file. Finally, an AndroidDriver is created by connecting to the Appium server URL, which starts the automation session on the target device.



The TestRunner Class — Connecting Cucumber with TestNG


The TestRunner class is the entry point for executing Cucumber tests. It extends AbstractTestNGCucumberTests, which bridges Cucumber with the TestNG framework so tests can be triggered and managed by TestNG. The @CucumberOptions annotation controls how the tests run — it points to the feature files location (src/test/resources/Features), the step definitions and hooks (com.stepDefinitions, com.appHook), and filters execution to only scenarios tagged with @tap. It also configures multiple report formats including Allure, JSON, HTML, and ChainTest for detailed test reporting, while monochrome = false keeps the console output colorful for easier reading.


🔹 com.pageObjects : This package contains all Page Object classes.Each module of the application has its own class where:

  • Locators are defined

  • Action methods are written

               Example: LoginPage, HomePage, CartPage

This helps in improving code reusability and maintainability.


🔹 Features : This folder contains Cucumber Feature files.These files are written in Gherkin language using Given, When, Then format to describe test scenarios in a simple way.



🔹 com.stepDefinitions : This package contains Step Definition classes.Each step in the feature file is mapped to a Java method here. It acts as a bridge between Feature files and Page Object classes.



🔹 Common : The Common package contains all the reusable utility classes that support the test framework.

  • ConfigReader.java — Reads values from the config.properties file such as device name, platform, app package, and server URL, keeping test data separate from code.

  • ExcelReader.java — Reads test data from Excel sheets, enabling data-driven testing by supplying different inputs to the same test scenario.

  • LoggerLoad.java — Sets up logging methods to track test execution flow, making it easier to debug failures.


How to Run Tests?

Follow these simple steps to execute the test suite:

Step 1 — Start Appium Server Open your terminal and start the Appium server by running:

appium

Make sure the server is running on http://127.0.0.1:4723

Step 2 — Launch Android Emulator Open Android Studio and start the emulator that matches the device name and version you configured in your config.properties file.

Step 3 — Run the Tests You can execute tests in two ways:

  • Via TestRunner class — Right-click on TestRunner.java and select Run As → TestNG Test

  • Via Maven command — Run the following in your terminal:

mvn clean test

Step 4 — View Reports After execution, reports are auto-generated at:

  • Allure → target/allure-results

  • HTML → target/CucumberReports/Skytube.html

  • JSON → target/CucumberReports/SkytubeJson.json


Conclusion:

In this blog, we built a Mobile Automation Framework step by step using Appium, Cucumber, TestNG, and Maven.

We learned how to set up the driver, write test scenarios, organize the project structure, and generate test reports.


Happy Testing !!

 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page