Cucumber / Gherkin - Preventing feature file proliferation


(rob) #1

Hi I’m currently using a cucumber implementation to test mobile apps on Android and iOS. I’m using a Git repo of gherkin scenarios tagged to identify the relevant apps and platforms (e.g. app1, app2, ios, android) where all the procedural elements of the test are abstracted out into the step definitions (written in Kotlin and SWIFT). I’m doing it this way to try and prevent unwanted proliferation of Gherkin scenarios where we might have multiple identical gherkin scenarios for different apps e.g. login fo app 1 and login for app 2

So if I give a pseudo code example

GENERIC GHERKIN SCENARIO

Feature: App log in

Scenario: User can log in with valid credentials
Given the user is on the log in screen
When the user attempts to log in with valid credentials
Then the user can log in

Note that there’s no detail in here about hard coded credentials, which fields credentials should go in or which buttons should get tapped etc . It’s a behavioural test and currently holds true for all our apps where there is a log facility.

Step definitions for App1

step(“the user is on the log in screen”) {
Launch app
Assert user is on log in screen
}

step(“the user attempts to log in with valid credentials”) {
Fill in these fields to log into App1
Tap login button
}

step(“the user can log in”) {
Assert user is now on correct post login landing page
}

Step definitions for App2

step(“the user is on the log in screen”) {
Launch app
Assert user is on log in screen
}

step(“the user attempts to log in with valid credentials”) {
Fill a whole set of different fields to log into App2
Tap login button
}

step(“the user can log in”) {
Assert user is now on correct post login landing page
}

My questions are

  1. ‘Does this look like a sensible approach to people’

  2. ‘Can people see any downsides to the way I’m doing it?’ One immediate downside seems to be that by having all the detail in the step definition it might make things awkward if I ever wanted to use the Gherkins as a guide for manual testers.

  3. How have others approached the same issue of preventing feature file proliferation?

Thanks
Rob