cancel
Showing results for 
Search instead for 
Did you mean: 

Database Assertion

Super Contributor

Database Assertion

Hello,
would it be possible to have a 'Database assertion' as a new feature. Most of my responses typically have to be validated against some value in a database. If there is a database assertion type, it would make things a lot easier.

In the meantime, what would be the best way to accomplish this.
3 REPLIES 3
Super Contributor

Re: Database Assertion

Hi!

hmm.. good idea! How would it be configured? Would it be together with the xpath assertion? ie the expected content field would somehow specify a database/table/row/column to match against?

Best bet currently is maybe to create a DataSource step to select the value for comparison and then compare either with a groovy script or a standard property-expansion in the expected value field

Hope this helps!

/Ole
eviware.com
Super Contributor

Re: Database Assertion

When I am creating a database assertion I am typically checking for a specific value (one column one row). Whereas in the datasource you can get multiple rows and columns, I think a database assertion would only contain one value.

So I guess datasource would be embedded inside the database assertion.
Super Contributor

Re: Database Assertion

Hi!

You could setup a DataSource teststep with a query that only selects one row (you can even use property-expansion in the sql query field) which would then be fetched when the testcase executes the step.. there is no requirement for you to hactually ave a DataSourceLoop step as well, so this step would only be run once (unless you loop over it in some other way.. )..

ie your TestCase could contain only

- DataSource -> fetch just one row
- Request -> with an xpath-match assertion that references the fetched row and/or its columns in the expected value

Hope this makes sense!

regards,

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
API Testing Mistake #2
APITestingMistake#2