Forum Discussion

strim355z's avatar
strim355z
Occasional Contributor
8 years ago

How to check a count against a db?

I have a get that returns 8 records.  If I do a JSONPath assertion for count from the outline view, it automatically populates 8 for me but how can I check that the count returned is matching the db count?  Thank you.

2 Replies

  • There are many ways to do it. But the easiest I think is to just create a JDBC test step and put your SQL query to retrun count form DB ( something like 'select count(*) count from table  where ..... ' )

     

    and then under your Json path assertion give Expected result as.

     

    ${#<jdbc_test_step_name#ResponseAsXml#//count}

     

    Regards,

    Gilu Gopi

     

     

    • strim355z's avatar
      strim355z
      Occasional Contributor

      Thank you Gilu I have much to learn. I created my jdbc teststep and my query returned 8, my jpath assertion looks a little different but it seems to be working!