Perfect Data Binding Workaround / Work With Any Data Type Easily

Windows 10 21H1 64-bit
Katalon Studio

I have a serious problem with Katalon Studio, that it binds all Variables to Test Cases as String and totally ignores selected Data Types. This appears to be true whether or not the “Bind to test case as String” checkbox is selected on the data file. I found other guys here on Forum or elsewhere on the Internet that said, that they couldn’t make it work neither, so I am convinced this isn’t actually working for anybody. But it is a serious problem, because at least boolean (to parametrize checkboxes for example), numbers and lists should really be working. Maybe even custom Data Types would be of use. But sadly, everything is just a string and it is painful to manually parse everything from String.

This is very weak point of Katalon Studio, so I believe you should highly PRIORITIZE IT :slight_smile:
Pleeeeease :pray: :pray: :pray: :grinning:

But I created awesome workaround myself, which allows to work with any data types easily.
I had an idea, to use Description column in Test Case Variables tab for writing your desired data type like this:
** Note, that I set all Types to String in Type column

Supported data types are:
String, Bool, Char, Byte, Short, Int, Long, Float, Double, LocalDate, LocalTime, LocalDateTime, ZonedDateTime, Period, Duration, List, Map and CustomData

There are only 2 things that needs to be done at the beginning of a project to make this work:

  1. Create package “Utils” in Keywords and place Data.groovy (2.4 KB) file under it:
  2. Add this method to TestListener:

    ** Note that this method will run only if you run whole TestSuite. If you run only single TestCase, this method won’t run, so data parsing won’t work.

And that’s it! This will automatically parse all your variables to desired data types and you can use them normally.

Now, if you want to use your own Custom Data Type, you can either implement ICustomTestData interface to provide your parsing logic, or just extend JsonTestData class to make it automatically parse using JSON.

1 Like

Now there are still few problems that persist even after creating this solution:

  1. My solution will be used only by people that discovers this, not by everyone => That’s why it should be made official.

  2. It would be much better to use Data Type in that Type column instead of Description column so everybody sees what data types can be chosen with that SelectBox (it could also look for your custom data types).
    And of course, there would be no mistyping like now can happen easily in Description column.

  3. Because all values is just a string that needs to be parsed, it’s hard to create these actual values. For example, when you want to write DateTime, you now don’t really know, what date format should be used. Or if you want custom data type, you have to write it like JSON. So when using Internal Data like a data source, there should be support tool for creating those values (like when doing Lists for example). You could just select year, month and day somewhere when Date is your data type and you wouldn’t have to worry about correct format.

  4. And it would of course allow validation of all data that will be used in Tests ( wheter they are in correct format and can be parsed without any problem). And it could run separately from Tests, like before all tests even run. So no tests would never fail because of problem with data parsing, because all problems would be known beforehand.

Hi Peter,

Thank you for the contribution, we will have a look into this

1 Like