Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

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

  • alibaba82's avatar
    alibaba82
    Super Contributor
    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.
  • omatzura's avatar
    omatzura
    Super Contributor
    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
  • omatzura's avatar
    omatzura
    Super Contributor
    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