Rows' count for a result-set


This assertion counts rows of a result-set and compares it to an expectation. The possible comparisons are equal, equal, more-than and less-than.

System under test

The system-under-test is a query, please reports to other tests for more information about how to define a query. More info here.

Assertion

The assertion consists in an xml element named row-count.

<assert>
  <row-count>
    ...
  </row-count>
</assert>

In this element, you must also specify an the comparison that you want to apply equal, more-than and less-than. You must also specify the reference to compare. Currently NBi only supports a fixed value.

<assert>
    <row-count>
         <less-than>10</less-than>
    </row-count>
</assert>

For the comparisons more-than and less-than, you can slightly change the behavior by adding the attribute or-equal and setting its value to true.

<assert>
    <row-count>
         <less-than or-equal="true">10</less-than>
    </row-count>
</assert>

Full example

<test name="Count of SalesTerritory is less-than or equal to 3" uid="0001">
   <system-under-test>
      <execution>
        <query connectionString="Data Source=mhknbn2kdz.database.windows.net;Initial Catalog=AdventureWorks2012;User Id=sqlfamily;password=sqlf@m1ly">
          select
            [Name], [CountryRegionCode]
          from
            [Sales].[SalesTerritory]
          where
            [Group]='Europe'
        </query>
      </execution>
   </system-under-test>
   <assert>
      <row-count>
        <less-than or-equal="true">3</less-than>
      </row-count>
   </assert>
</test>