QApilot - AI-Powered Mobile App Testing
    Back to Blogs
    Cucumber BDD Testing for Mobile Apps: Gherkin to Appium - QApilot Blog

    Cucumber BDD Testing for Mobile Apps: Gherkin to Appium

    Summarise with AI

    Key takeaways

    Implementation guide to Cucumber BDD testing on mobile: separate BDD, Gherkin, Cucumber and Appium, wire a Gherkin scenario to device assertions, and compare coded stacks with reviewed AI authoring.

    How-To GuidesCucumberBDD TestingMobile TestingAppiumGherkinTest Automation

    Harini Mukesh

    Product Marketing Analyst

    11 min read

    Cucumber BDD testing turns agreed examples of software behaviour into executable checks: Gherkin describes the example, step definitions implement it, and a driver such as Appium operates the mobile app. A .feature file alone does not tap a screen, wait for a spinner or assert that an order shows as Confirmed. Those outcomes need agreed examples first, then steps wired to code that talks to a real device.

    Behaviour-driven development starts with collaborative discovery, not with syntax. Product, engineering and QA agree on concrete cases of expected behaviour, write them in a shared language and automate the checks that earn their keep. This guide maps the chain for Android and iOS, walks one fictional order-history scenario from Gherkin through an assertion, then compares a coded Cucumber stack with a reviewed AI authoring workflow that is not a Cucumber runner.

    What is Cucumber BDD testing?

    Cucumber BDD testing means expressing agreed behaviour as Gherkin scenarios and running them through Cucumber so each step calls real implementation code. Four pieces do different jobs and should stay distinct.

    BDD is the collaborative process. Teams discover examples before coding, formulate them as readable specifications and automate useful checks. Writing Given/When/Then after the feature already shipped is not the same practice.

    Gherkin is the structured scenario language. It gives scenarios a grammar of Given (context), When (event) and Then (expected outcome), plus Scenario Outline, Examples and Background. The Gherkin reference defines those keywords; Gherkin itself never opens an app.

    Cucumber matches each scenario step to a step definition and runs the matching method. The Cucumber introduction describes executable specifications and reports. Cucumber is not a mobile driver and does not know about Accessibility IDs or permission dialogs.

    Appium (or another driver) automates the device UI. Platform drivers talk to Android and iOS; Cucumber only decides which step method to call next.

    Cucumber BDD testing is the composition of those layers: agreed examples, Gherkin text, Cucumber bindings and a driver that reaches the phone. Pasting Given/When/Then into a ticket without matching code is prose, not cucumber BDD testing.

    How do Gherkin scenarios describe mobile behaviour?

    Gherkin scenarios describe observable business outcomes on the device, not tap coordinates. Keep UI mechanics behind step definitions so the feature file stays readable. Good mobile test cases already name preconditions, actions and expected results; Gherkin keeps that structure executable.

    One fictional scenario runs through this article:

    Feature: Order history
      Scenario: A confirmed order appears in history
        Given a signed-in customer has a confirmed test order
        When the customer opens order history in the mobile app
        Then that order is listed with status "Confirmed"
    

    The Given step seeds a dedicated test customer and a confirmed order through a test API or fixture helper, then stores the order ID for this scenario only. Credentials and real customer records never belong in the feature file or fixtures. The When step uses the signed-in session, opens order history and waits for the list to settle. The Then step finds the row for that order ID and asserts the displayed status equals Confirmed. Completing navigation is not the assertion; the status string is.

    A Scenario Outline with an Examples table can vary status values or locales without duplicating the scenario. Background can hold repeated context such as signing in, but scenarios should not share mutable state. Each run needs its own order ID and teardown so yesterday's Confirmed row cannot pass today's check by accident.

    How does Cucumber run tests through Appium?

    Execution follows a fixed chain. Cucumber loads the feature, matches each step to a method, that method calls a screen or page object, the page object talks to an Appium driver, the driver commands an Android or iOS device or emulator, and the assertion plus report close the loop.

    Step definitions are methods whose expressions match one or more Gherkin steps. The method body performs the action or check, usually by calling a screen object that hides locators, waits and gestures. Published mobile Cucumber stacks often compose feature files, step definitions, page objects and a runner; treat them as structure references, not copy-paste dependency pins.

    Illustrative Java-style step (not a runnable project; page-object and session helpers are assumed to exist elsewhere):

    // Illustrative only. Wire your own OrderHistoryScreen and Appium session.
    @Then("that order is listed with status {string}")
    public void thatOrderIsListedWithStatus(String expectedStatus) {
        String orderId = scenarioContext.getOrderId(); // set in the Given step
        String actual = orderHistoryScreen.statusFor(orderId); // uses Appium finds/waits
        assertEquals(expectedStatus, actual);
    }
    

    Pseudocode for the Given helper that seeds data:

    # Illustrative helper, not a product feature
    order = testApi.createConfirmedOrder(forUser = testCustomer)
    scenarioContext.store(order.id)
    # After the scenario: testApi.deleteOrder(order.id) and end the Appium session
    

    Hooks create and quit the Appium session per scenario or feature, depending on device cost. Prefer explicit waits on element conditions over fixed sleeps. Isolate test data so parallel runs do not collide on one order ID. Reports should capture the scenario name, matched steps, failure screenshots and the device or cloud session id.

    Device and cloud setup sit outside Cucumber. Capabilities, signing, app install and permission grants belong in session configuration. Cucumber decides which scenario ran and whether each step passed; Appium and the cloud decide whether the tap reached the right control.

    What makes mobile BDD tests expensive to maintain?

    The feature file stays cheap; the bindings and device layer do not. Locator churn is the usual bill. A renamed Accessibility ID or rearranged order-history cell breaks the page object, not the Gherkin sentence. Push locators, waits and gestures behind screen objects so a layout change edits one class instead of every history step.

    Shared steps create coupling when one Given is reused across unrelated journeys and assumes a tab bar another flow removed. Prefer smaller, journey-specific steps over a giant shared vocabulary. Scenario state leaks when a Background signs in once and every scenario mutates the same cart; isolate users and orders, then tear them down.

    Android and iOS diverge on permissions, deep links and system dialogs. Dismissing a notification prompt on Android may need a different path on iOS even when the business Then is identical. Platform-specific code belongs in drivers or screen objects, not in the feature file. A healed or rewritten locator does not change the expected business result: if the rule still says Confirmed, the Then must still assert Confirmed.

    How should you choose a BDD testing framework?

    A BDD testing framework has to fit the team's language, mobile driver, reporting and willingness to maintain bindings. Cucumber is common because Gherkin is widely understood and bindings exist for many languages, but it is not tied exclusively to UI tests or to Appium. The same business examples can drive API or unit checks when a device run would be wasteful.

    What each layer does

    Layer Responsibility Mobile example What it does not replace
    BDD Collaborative discovery before coding Roles agree a confirmed order must appear in history Writing code, locators or device allocation
    Gherkin Scenario grammar for readable specifications Given/When/Then in a .feature file Finding elements or asserting UI state
    Cucumber Matches steps to methods and runs them Loads the order-history scenario and calls step definitions Driving the phone or cloud sessions
    Step definitions / page objects Implementation, waits and assertions statusFor(orderId) reads the cell and asserts Confirmed Product discovery or device provisioning
    Appium Device UI automation through platform drivers Tap history and read status on Android or iOS Deciding which business examples matter
    Device / cloud Execution environment Emulator, real device or cloud session Writing scenarios or reviewing rules

    Choosing an execution and authoring approach

    Approach Scenario input Execution implementation Platform scope Review / maintenance responsibility
    Cucumber + Appium Gherkin .feature files Coded steps and screen objects calling Appium Android/iOS with matching drivers Engineers own locators, waits, data, reports
    Cucumber + non-UI code Same Gherkin business examples Steps call APIs or domain services Not a device test; under a thin UI set Engineers keep bindings; no device flakiness
    QApilot CoWork Written plain-English or BDD cases (editable steps) AI planning with reviewable live-device recordings Android with LambdaTest; not a Cucumber runtime People edit BDD input and accept, edit or complete recordings

    Cucumber plus Appium is the classic coded path. Cucumber plus non-UI code reuses the same examples without a phone for every check. CoWork is a separate reviewed authoring option for written Android cases; it is not another Cucumber library and does not import .feature files. See automated software testing tools for broader selection, and QApilot and Appium for the driver-layer comparison.

    Where does CoWork fit for written Android test cases?

    CoWork is QApilot's human-in-the-loop authoring path for written mobile cases on Android. You ingest plain-English or BDD-style cases (including Excel upload or manual creation), review and edit the generated BDD steps, then plan and execute on a live Android device with LambdaTest. CoWork reads the live screen, selects actions and can replan after an unexpected state. Plan History and Replans show what happened. A person Accepts Steps, Records Manually, or Edits and Reruns; after acceptance the recording joins ordinary suites and reporting. See the CoWork authoring docs for the full flow.

    That workflow is not a drop-in Cucumber runner. The docs do not establish native .feature import, reuse of Cucumber-JVM step definitions, Scenario Outline tag execution or Cucumber report interchange. Excel upload is not .feature import. Do not treat the word BDD in CoWork as proof of Cucumber compatibility.

    Separately, QApilot's Android crawler explores the app and records screens, paths and steps as a knowledge graph of app flows. That helps people understand the app; it is not evidence that CoWork executes Cucumber features or heals locators through the graph. Locator healing with human review stays distinct from CoWork replanning and crawler exploration.

    On iOS, QApilot supports record and playback, locator healing a person reviews before saving, and shared cases with platform-specific steps where navigation differs. Those workflows are separate from CoWork, whose documented execution scope is Android on LambdaTest. See the XCUITest guide for Apple UI details. Device clouds remain execution infrastructure; QApilot complements them.

    When should a mobile team use BDD, and when should it skip it?

    Use BDD when business rules are disputed across roles and the team needs shared acceptance examples before coding. Order status, eligibility and refunds are typical candidates because a wrong Then costs a release argument. Skip the Gherkin layer when nobody outside engineering reads the feature files, or when it only wraps page objects without improving collaboration. Keep unit and API checks under a small device acceptance set so mobile regression testing does not push every rule through a phone. Pilot one critical journey, agree on three examples, automate at the lowest useful layer and inspect the evidence before expanding.

    Next step

    Pick one release-critical mobile journey, write three agreed examples, automate them at the lowest layer that still proves the outcome, and read the failure evidence on a real device before scaling. The binding between an example and an observable result makes the check trustworthy.

    Written by

    Harini Mukesh

    Harini Mukesh

    Product Marketing Analyst

    Harini is a Product Marketing Analyst at QApilot with a background in Psychology and Data Analytics. She is interested in understanding user behavior and translating insights into structured, meaningful solutions. She enjoys working at the intersection of data, content, and product thinking, and is particularly curious about how technology and human behavior come together to shape better user experiences.

    Frequently asked questions

    What is BDD testing?

    BDD testing is a collaborative practice where business, development and testing roles agree on concrete examples of expected behaviour, write them as specifications and automate the checks that matter. Typing Given/When/Then without discovery or automation does not by itself mean the team practices BDD.

    Is Cucumber a BDD testing framework?

    Cucumber is a tool that executes specifications written to support BDD. Gherkin structures the scenarios; step definitions connect each step to code. BDD remains the collaboration process around examples, which Cucumber can help automate but does not replace.

    Can Cucumber test Android and iOS apps?

    Yes, when step definitions call Appium (or another suitable driver) with the right platform capabilities. Cucumber orchestrates the scenario; your team still implements and maintains device setup, locators, waits, isolated test data and assertions.

    How are Cucumber and Appium different?

    Cucumber matches business-readable scenario steps to code and reports pass or fail per step. Appium automates taps, swipes and reads on a device UI through platform drivers. They sit at different layers and combine well: Cucumber decides which behaviour to run; Appium performs the UI actions.

    Does CoWork run existing Cucumber feature files?

    No. CoWork ingests written cases, produces editable BDD steps and yields reviewable Android recordings on LambdaTest. The docs do not establish .feature import or reuse of Cucumber step definitions. Shared BDD vocabulary does not imply Cucumber runtime compatibility.

    Does CoWork support iOS?

    The documented CoWork execution workflow is Android with LambdaTest. QApilot's iOS support covers recording and playback, reviewed locator healing, shared cases with platform-specific steps and execution reports, separate from CoWork.

    Read More...

    Get started

    Start Your Journey to Smarter Mobile App QE

    Rethink how your team approaches mobile testing.

    QApilot - Mobile-First Businesses Need Mobile-First App Testing | Product Hunt
    SOC 2 Type 2 compliance badge
    SOC 2: In Progress
    HIPAA compliance badge
    HIPAA: In Progress
    Copyright © 2026 | Powered by QApilot