Skip to content
ostry202 edited this page Feb 12, 2021 · 8 revisions

We can compare query to expected data in csv file

<cmpSqlResultsTest>
    <compare mode="FILE" diffTableSize="5" chunk="1000" fileOutputOn="true">
        <sql datasourceName="PostgreSQL" filename="sql1.sql" />
        <!-- separator -> CSV file separtor. Default is "," -->
        <file filename="fileSource.csv" separator=";" startAtRow="1" />
    </compare>
</cmpSqlResultsTest>
  • diffTableSize - number of differences which will be displayed in logs. Even records from first DB/SQL and odd from the second (so the table will have two times more rows than defined here). Default is 5.
  • chunk - number of differences after which further comparison is stopped. 0 (or if not set) means never stop -> go to the end of all records. Number of differences visible in test result may be smaller than real one if FETCH comparator stopped his job because of chunk. So if the number of differences is equal to the chunk, it may mean that there are more differences. Default value is 0.
  • fileOutputOn - boolean value - if true all results will be saved in CSV files (same name as XML test configuration FILE but with different prefix and extension). File may be incomplete (if chunk > 0 - see above). In case of FILE comparator only 1 file will be generated: test_name_minus.csv - CSV with results returned by MINUS sql query Default is false.
  • file filename - name of csv file with data to compare with query
  • separator - CSV file separtor. Default is ","
  • startAtRow - default is 1 (all rows from file will be compared). Set it to e.g. 2 to skip comparing first row in file if contains headers

fileSource.csv:

"1";"1970 Napa Ct.";"NULL";"Bothell";"79";"98011";"2002-01-04 00:00:00.000"
"2";"9833 Mt. Dias Blv.";"NULL";"Bothell";"79";"98011";"2003-01-01 00:00:00.000"
"3";"7484 Roundtree Drive";"NULL";"Bothell";"79";"98011";"2007-04-08 00:00:00.000"
"4";"9539 Glenside Dr";"NULL";"Bothell";"79";"98011";"2003-03-07 00:00:00.000"
...