Perfect Data Binding Workaround / Work With Any Data Type Easily

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:
87d0bad6a246bc2aa7f5a6a8295c0b6c376d6545
** 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 Data.zip (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