# Where should I write the code of the actual tests?

**URL:** <https://forum.katalon.com/t/where-should-i-write-the-code-of-the-actual-tests/53425>\
**Category:** Miscellaneous\
**Tags:** start-page\
**Created:** [March 30, 2021, 4:08pm UTC](https://forum.katalon.com/t/where-should-i-write-the-code-of-the-actual-tests/53425 "2021-03-30T16:08:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Questioner](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/questioner/32/16103_2.png) [@Questioner](https://forum.katalon.com/u/Questioner)\
**Post date:** [March 30, 2021, 4:08pm UTC](https://forum.katalon.com/t/where-should-i-write-the-code-of-the-actual-tests/53425/1 "2021-03-30T16:08:08Z")

</div>

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](https://docs.katalon.com/katalon-studio/docs/cucumber-features-file.html#define-steps) 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:

- **[calculator-bdd-tests](https://github.com/katalon-studio-samples/calculator-bdd-tests)**
- **[katalon-bdd-cucumber-tests](https://github.com/katalon-studio-samples/katalon-bdd-cucumber-tests)**

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](https://docs.katalon.com/katalon-studio/docs/create-test-case.html). And in `Include/scripts/groovy` you can find how the test are actually called ([example](https://github.com/katalon-studio-samples/katalon-bdd-cucumber-tests/blob/master/Include/scripts/groovy/login/LoginSteps.groovy)):

`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.

---

<div class="post-metadata">

**Author:** ![luc.namur](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/luc.namur/32/20332_2.png) [@luc.namur](https://forum.katalon.com/u/luc.namur)\
**Post date:** [April 10, 2021, 9:09pm UTC](https://forum.katalon.com/t/where-should-i-write-the-code-of-the-actual-tests/53425/2 "2021-04-10T21:09:54Z")

</div>

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
