Automation Test Using Cucumber
What’s New
Hi All, it’s been a while since my first article was released. I hope you enjoy your long “WFH” lol. Since that, I have some problems so I can not continue to write down my next article in this platform. So I hope we are in a good condition right now and for the next capture. lol. Ok, I this article I would like to share my knowledge about cucumber automation test using katalon studio. But before you read this article, I assume that you are familiar with katalon studio syntax such as WebUI.setText(findTestObject(“”)),WebUI.verifyElementPresent(findTestObject), etc.
If you ever hear about TLD(Test Last Development),TDD(Test Driven Development), and BDD(Behavior Driven Development) it means I have not to explain it clearly. But if you have not, you can read it from the internet as well. lol. But in this article I will show you the best descriptions about all of them.
So how about BDD?? actually, BDD is expansion of TDD. But the different is, BDD just like a real documentation which is all the people who read this document will understand with simple explanation(user stories).
BDD Cucumber Test in Katalon Studio
Ok, so first of all I recommend you to read this pure documentation about (cucumber) so we have a same perception about it. Because there are some prerequisites and provisions that have to follow. In this example project, you can use some of programming language that you are familiar with. such as java, ruby, javascript, scala etc. Before I forget to inform you, I hope you are familiar with this keyword in cucumber syntax(Feature,Scenario,Given,When,Then,And).I’t all just like a human language in our daily life right?. I will give you simple Gherkin syntax, for example :
Feature : Fall in love
Scenario : Bram is falling in love with Brem
Given Bram sees Brem on Instagram
When Bram open his Instagram
And Bram search for Brem’s Instagram account
And Bram types “Brem” on search menu
And Bram likes all the photos
Then Bram is going to sleep have a sweet dream about Brem
I’m going to create simple project called sign in to amazon website. I think you are familiar with this website, if you haven’t an account in that website, you have to make your own account because we are going to use it to running the automation test. First of all, just create a new file on katalon studio project(Include->Features)I have a file called “loginAmazon.feature” just like this
And after that, just create a file on Script folder(Include->scripts) called “loginAmazonSteps” which the content is :
After finished the two files, just run the feature file and then you will get the result like this:
Which means there is no error and all test case is running well as expected. All the function that we created on loginAmazonSteps.groovy is very basic. So I will modify the code so it looks like the professional code. So the code will be shown like this
And then you can create test case to all cucumber keyword on your own test case. When you add the test steps you can select Run Feature File and the input column you can fill with the id of your feature. Copy ID. You can also create the test suite to see the report of your project.
So, it’s all about the article, if you have any question or ask the full project, you can download it from my gitlab