Dynamic Test Data/How to Reload Test Data Binding?


#1

Perhaps there is another design pattern we should be following, so please feel free to offer up other patterns which can solve this problem if we are indeed at a dead-end.

Our test cases involve entering form data on a web-application, however the form data values need to be generated before the test case runs, as execution of the test will consume the data and not allow us to re-run the test case without generating a new data set.

Our plan was to ingest data into our database in the setup phase, and write this dynamic data into CSV files which are already data-bound to Katalon Test Data objects and the accompanying test case. I have most of this working fine, however I have found that the Test Lifecycle causes the data binding to occur before the Test Listener / Test Suite Setup hooks, so the data is already stale.

Based on these resources, this is what I believe is happening:
Lifecycle: https://docs.katalon.com/katalon-studio/docs/test-listeners-test-hooks.html#example
startTestSuite entry point: https://github.com/katalon-studio/katalon-studio-testing-framework/blob/64c7915b8d478adac844b7b7da6cd15b38aead4c/Include/scripts/groovy/com/kms/katalon/core/main/TestCaseMain.java#L146

Execute Test Suite

  • startTestSuite is called with the existing CSV file loaded as the data binding
  • listeners/test suite setup methods are called – we create our new data objects in the database and write their IDs to the CSV
  • test cases run with the original data binding values

Any help would be greatly appreciated.


#2

Hi Scott,

I think in your case, you need to directly read the CSV while your test is running. It means you need a class that will read that CSV file so that you can get the latest record that you need.

Kindly see this link in reading CSV file:

Hope that helps. . . :slight_smile:


#3

Hi Arnel,

Thank you for the suggestion. I looked at this solution and it would remove the ability for our test case to use variables, which is one of the features we’ve chosen Katalon for.

The reason for this is that our test cases need to be run individually, as well as a part of larger workflows. Consequently, they need to be parameterized in such a way that they can be run from a CSV, as well as via the Run Test Case action by other tests.

Your suggestion of embedding the test data into the test case seems like an anti-pattern, as it would require a lot of repeated boilerplate and reduce flexibility of the Katalon project. I’d rather better understand why test setup cannot occur before data binding, or if another hook could be added for this stage.