Forum Discussion

sprice090161's avatar
sprice090161
Contributor
7 years ago

How to validate multiple sets of output data within a single response?

My application request returns 1 to many datasets to the user in a single response.  For example the user requests a loan, and the response will contain a structure for each supported loan offing in the sql db. Since I configure the DB with the supported offer(s), I will always know how many are supported and thus how many responses to expect. I could simply start writing validation expecting a known quantity of nodes in the output, and then create sets of redundant assertions 1 per expected offer in the response.

 

Is there a smarter way combining DB queries to to get counts and data, with assertions at the request output that would validate each child with in each set?

2 Replies

    • sprice090161's avatar
      sprice090161
      Contributor

      Thank you for your response.

      Yes I'm aware of the script assertion, and I recognize that I this will be a script assertion. What I'm looking for is a typical strategy used in writing such a script.

       

      For example:

       

      I want to assume that I don't know how many offers would be in the response. The first part of the assertion (Or some prior test step) might be to perform a DB query to discover the number of offers available, as my Expect Data. Then capture the number of offer nodes in the output , Actual Data,  and compare Expected and Actual values.

       

      I want to capture and store the output data as well.

       

      I'm not sure how to work with the JSON response and order the data into something I can compare against.

       

      Since writing this I have added a Datasource of type JDBC, which has queried the database and returned each offer and their related properties in the same order as the offers appear in the output. Now I need a way to iterate through each offer and perform assertions on each property Expect vs. Actual Values.