Skip to content

Storing queries in separated files or inline in xml test definitions

Jakub Raczek edited this page Dec 8, 2016 · 4 revisions

You can store SQL queries inline in xml test definition:

<cmpSqlResultsTest>
    <compare mode="FETCH" fetchSize="100" chunk="10" diffTableSize="5" fileOutputOn="false">
        <sql datasourceName="SQL_SERVER">
            <![CDATA[
SELECT [AddressID]
      ,[AddressLine1]
      ,[AddressLine2]
      ,[City]
      ,[StateProvinceID]
      ,[PostalCode]
      ,convert(varchar(30),[ModifiedDate],121)
 FROM [AdventureWorks2008R2].[Person].[Address]
 WHERE ModifiedDate BETWEEN '@datefrom@' AND '@dateto@'
 order by AddressID
         ]]>
        </sql>
        <sql datasourceName="PostgreSQL">
            <![CDATA[
SELECT addressid, addressline1, addressline2, city, stateprovinceid, postalcode, modifieddate
	FROM public.personaddress
   WHERE modifieddate BETWEEN '@datefrom@' AND '@dateto@'
   order by addressid;
        ]]>
        </sql>
    </compare>
</cmpSqlResultsTest>

or in separated files

<cmpSqlResultsTest>
    <compare mode="MINUS" defaultDatasourceName="PostgreSQL" diffTableSize="10">
        <sql filename="sql1.sql" />
        <sql filename="sql2.sql" />
    </compare>
</cmpSqlResultsTest>

or use mix of both:

<cmpSqlResultsTest>
    <compare mode="MINUS" defaultDatasourceName="PostgreSQL" diffTableSize="100">
        <sql filename="sql1.sql" />
        <sql>
            <![CDATA[
select addressid, addressline1, addressline2, city, stateprovinceid, postalcode, modifieddate
from public.personaddress
        ]]>
        </sql>
    </compare>
</cmpSqlResultsTest>