Cucumber BDD test with Katalon Studio
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.
Setup Your Project 🔥
First open your katalon studio, then create a new project
, give it a name
and select the Mobile
type.
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
.
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
.
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.
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
.
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
.
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.
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.
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 👍