Forum Discussion

Arunachalam_RM's avatar
Arunachalam_RM
Occasional Contributor
4 years ago
Solved

how to compare multiple database values with api response in single shot without groovy scripting?

i have created one table in my sql. i have created one 1 api json response which is coming from my local machine.

now i need to compare response values with databases values as loop.how to do that ?

I add assertion in the request itself.but its comparing all the json values with the last updated mysql database value.

 

 

 

  • ChrisAdams's avatar
    ChrisAdams
    4 years ago

    You can supply a fixed value, but if you're testing the API response matches the datasource value, you should be able to right-click in expected value cell and from the context menu, select Get Data.  Get Data allows you to select a value from anywhere within SoapUI (it's a brilliant little feature).  You could also specify the expected response from your datasource. E.g. {DatasourceStep#value}.  

     

    Might be a bit of a pain, but it's Groovy free.  Personally, when managing multiple entries in a single response and rows form a db and looping is required, I'd be more inclined to use Groovy.

12 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

     

    I genuinely cannot think how you might achieve this without any Groovy scripting.  With scripting, it shouldn't be too difficult.

     

    I'd be interested to see what the other contributors come up with...

     

    Chris

  • RJ's avatar
    RJ
    New Contributor

    Hi Arunachalam_RM

    If you have readyapi (Licensed version) then there is one assertion "Mesage Content Assertion", there you can use property transfer to check and configure the values from the Datasource and the response dynamically.

    • richie's avatar
      richie
      Community Hero
      Hey RJ,

      Can you please expand your answer? As far as i was aware the Message Content Assertiom allows you to create multiple assertions against a single response payload, so i'd welcome being educated how to do this if its possible!

      Arunachalam_RM needs to cycle through test responses, but they wont all appear in one payload response...hence the need to cycle. So using the Message Content Assertion wouldnt provide any additional functionality to help Arunachalam_RM do what he needs....it'd be the same as adding in a typical xml content match assertion.

      Or am i misunderstanding the requirements?

      Also Arunachalam_RM is still gonna need groovy to do the comparison, right?

      Cheers,

      Rich
    • Arunachalam_RM's avatar
      Arunachalam_RM
      Occasional Contributor

      every response field ,we need to dynamically set right? (it willl take lot of time?)if i am setting it is taking last value from database

       

  • RJ's avatar
    RJ
    New Contributor

    Hi Arunachalam_RM,

    if your query is resolved please mark it as solved, if not then please reiterate your question