Cucumber BDD test with Katalon Studio

sam nursanto
TelkomDev
Published in
3 min readAug 9, 2022

In my previous article, we have talked about BDD and how to create feature file, Now let’s use the scenario as test cases, for this example i will use .features file here.

Cucumber in Katalon studio

Setup Your Project 🔥

First open your katalon studio, then create a new project, give it a name and select the Mobile type.

Katalon studio new project

In your Tests explorer expand Include/features import your feature file there, expand scripts/groovy/(default package) then right click and create a new step definition .

Tests Explorer

In the LoginSteps.groovy create a class like below and then save file, if you open the Login.feature file there will be a yellow marks on the steps, to remove that mark you can right click on the step and then select recalculate steps.

LoginSteps.groovy

Mobile Recorder

Okay here we will use mobile recorder, to do that we have to select mobile recorder icon and select Android Devices as shown below.

Run mobile recorder

When use mobile recorder you have to connect your real device and enable usb debugging in developer option or you can use emulator.

After that, you can select Device Name with your device, select Start with with Application File (you can select Application Id but in this case i use Application File) and then browse your .apk in Application File, you can download the my example here, and then select start.

Mobile recorder

your screen now will be like below, at the right side it will be your device, you can click on any elements and add action in AVAILABLE ACTIONS then your actions will be record at the left side, do all actions refer to your Login.feature file, if you feel you have done all the steps then select save script, select the object repository and name it LoginTest.

Mobile recorder start

Open your LoginTest, you can see generated code from the mobile recorder, then copy the code to your LoginSteps.groovy, if there is an adjustment then do it. the complete LoginSteps.groovy will shown as below.

LoginSteps.groovy (completed)

Run The Test 🥳

Run the test

For running the test you have to open Login.feature and then select Android as above and boom, your device will run automatically and after the test is finished you can see the test results.

test result

That’s all, thank you for reading this article to the end, if you like this article you can give me a clap 👏, and if you have any question we can discuss in the response section, thank you 👍

--

--

sam nursanto
TelkomDev

Developer android, who curious about all tech