Call the same Test Case twice with a Custom Keyword

I recently had cause to run a series of tests where I needed to call the same Test Case multiple times, something Katalon Studio does not inherently support. For my test, I wanted to enter several pieces of information into a form, then perform the same validation steps to check table data. The validation steps are the same each time, so I wanted to reuse the test case. No such luck, Katalon Studio does not allow you to add the same Test Case name to the Test Suite.

My first thought was to duplicate each Test Case multiple times, putting a number in front. That seemed awkward and wasteful. I then noted I could go into the Test Suite XML file itself and repeatedly add the same Test Case name multiple times.

While interesting, each Test Case is tied to a GUID, so I would need to make a fake one and that's by no means to maintain. And if someone makes a change to the Suite, most likely everything will come apart like a house of cards.

Turns out I can do what I want by creating a Custom Keyword that calls all my Test Cases. My Test Case will prepare all the data by populating the fields, then at the end of Test, there will be a call to the Custom Keyword, which will run all the tests. It sounds a little odd, but this is at least easy to maintain and is far cleaner than hacking together an XML file.

The structure of the Custom Keyword looks like this:

@Keyword
    def verifyData(){
        WebUI.callTestCase(findTestCase('Read Table Values'), [:], FailureHandling.STOP_ON_FAILURE)
        WebUI.callTestCase(findTestCase('Read Savings Totals'), [:], FailureHandling.STOP_ON_FAILURE)
        etc
        etc
        etc
    }

The Test Suite will contain calls to the Test Cases that populate the data. The Test Cases will each call the Keyword to validate the data. It's not the most elegant of solutions, but it certainly works and gets the job done.

<Festive>

Author Signature for Posts

0