Skip to content

NMB_OF_RESULTS

Jakub Raczek edited this page Mar 13, 2017 · 11 revisions

We can assert number of rows returned by query to predefined value

Following query is executed in db engine:

Select COUNT(*) FROM (Query) countTable;

do not put semicolon at the end of query.

<cmpSqlResultsTest>
    <compare mode="NMB_OF_RESULTS">
        <sql datasourceName="PostgreSQL">
            <![CDATA[
SELECT addressid, addressline1, addressline2, city, stateprovinceid, postalcode, modifieddate
	FROM public.personaddress
    LIMIT 1
        ]]>
        </sql>
        <assert type="EQ">1</assert>
        <assert type="NE">0</assert>
        <assert type="LT">2</assert>
        <assert type="LE">1</assert>
        <assert type="GE">1</assert>
        <assert type="GT">0</assert>
    </compare>
</cmpSqlResultsTest>
  • datasourceName - name of connection to database engine defined in cmpSqlResults-config.xml file Supported assertions:
  • EQ (equal),
  • NE (not equal),
  • LT (less than),
  • LE (less or equal),
  • GE (greater or equal),
  • GT (greater than)

You can combine multiple assertions at the same time.

If you do not specify any assertion, the test will pass