Where should I write the code of the actual tests?

I’m using Katalon Studio with Cucumber for BDD Testing on mobile.

I have a question about where I should write the actual test code. With “actual test code” I mean the code actually used to interact with the mobile device.

In the official documentation it seems that it should be written into Include/scripts/groovy: and this was what I was doing. Later, changing the name of an object in the Object Repository, from oldName to newName, I noticed that in my groovy file I still had the previous name:

Mobile.verifyElementExist(findTestObject('oldName'), 10)

So I had a feeling that I was writing the code to them in the wrong place. I searched again, this time on the official Katalon Sample repository, and I found some examples:

As you can see, the actual test code is written into Test Cases. In fact if I write my code in Test Cases I can freely change the objects name, and in addition there are some other useful features. And in Include/scripts/groovy you can find how the test are actually called (example):

WebUI.callTestCase(findTestCase('Web UI Tests/Advance Tests/Pages/Dashboard Page/The Dashboard Page is loaded successfully'), [:], FailureHandling.STOP_ON_FAILURE)

So my question are: where should I write the code of the actual tests?
How should I organize the files for BDD Testing with Cucumber?

Thanks.

1 Like

I will personnaly not write code inside test case unless it is really necessary.

I’m writing most of my code inside Include/scripts/groovy which include step and class (in order to avoid code redundancy).

Test case are only here in order to call your cucumber feature

But if you decide to write some tests without cucumber then you could indeed write it directly in a test case.

Personnaly, I try to have a class/object approach so I like using Include/scripts/groovy for that

1 Like