Interpreting the output

A clean SQLUnit run will look something like the example below. This is the output from the test suite. Notice that the ant target sqlunit uses the standard JUnit output formatter but only writes its log to STDOUT, so its output is all grouped neatly in one place.


$  ant sqlunit -Dtestfile=test/postgresql/test.xml

Buildfile: build.xml

init:

test-ant-task:
  [sqlunit] Getting connection...
  [sqlunit] Setting up test...
  [sqlunit] Running test[1]: Adding department HR
  [sqlunit] Running test[2]: Adding department InfoTech using non-Callable form
  [sqlunit] Running test[3]: Adding Employee John Doe to InfoTech
  [sqlunit] Running test[4]: Adding John Doe again
  [sqlunit] Running test[5]: Adding Jane Doe to HR
  [sqlunit] Running test[6]: Adding Dick Tracy to InfoTech
  [sqlunit] Running test[7]: Updating Hourly Rate for John
  [sqlunit] Running test[8]: Looking up John Doe by name
  [sqlunit] Running test[9]: Looking up all employees in InfoTech
  [sqlunit] Running test[10]: Adding timecard for John
  [sqlunit] Running test[11]: Adding another timecard for John
  [sqlunit] Running test[12]: Adding timecard for Dick
  [sqlunit] Running test[13]: Getting monthly report for InfoTech
  [sqlunit] Tearing down test...
  [sqlunit] .
  [sqlunit] Time: 3.795
  [sqlunit]
  [sqlunit] OK (1 tests)
  [sqlunit]

BUILD SUCCESSFUL

Total time: 4 seconds

By default, SQLUnit will not consider a test failure as sufficient reason to stop the test suite from completing, since a test suite can contain unrelated tests that may not depend on each other. If you need SQLUnit to stop processing the suite after it encounters a test failure, set the haltOnFailure attribute to true. Here is an example of SQLUnit generating an error, with inline pointers to comments.


Buildfile: build.xml

init:

test-ant-task:
  [sqlunit] Getting connection...
  [sqlunit] Setting up test...
  [sqlunit] Running test[1]: Adding department HR
  [sqlunit] Running test[2]: Adding department InfoTech using non-Callable form
  [sqlunit] Running test[3]: Adding Employee John Doe to InfoTech
  [sqlunit] Running test[4]: Adding John Doe again
  [sqlunit] Running test[5]: Adding Jane Doe to HR
  [sqlunit] Running test[6]: Adding Dick Tracy to InfoTech
  [sqlunit] Running test[7]: Updating Hourly Rate for John
  [sqlunit] Running test[8]: Looking up John Doe by name
  [sqlunit] Running test[9]: Looking up all employees in InfoTech
  [sqlunit] Running test[10]: Adding timecard for John
  [sqlunit] Running test[11]: Adding another timecard for John
  [sqlunit] Running test[12]: Adding timecard for Dick
  [sqlunit] Running test[13]: Getting monthly report for InfoTech
  [sqlunit] No match on variable at [rset,row,col]=([1,2,4] (1)
  [sqlunit] *** expected: (2)
  [sqlunit] <result>
  [sqlunit]   <resultset id="1">
  [sqlunit]     <row id="1">
  [sqlunit]       <col id="1" type="VARCHAR">Information Technology</col>
  [sqlunit]       <col id="2" type="VARCHAR">Dick Tracy</col>
  [sqlunit]       <col id="3" type="INTEGER">13</col>
  [sqlunit]       <col id="4" type="NUMERIC">50.00</col>
  [sqlunit]       <col id="5" type="NUMERIC">650.00</col>
  [sqlunit]     </row>
  [sqlunit]     <row id="2">
  [sqlunit]       <col id="1" type="VARCHAR">Information Technology</col>
  [sqlunit]       <col id="2" type="VARCHAR">John Doe</col>
  [sqlunit]       <col id="3" type="INTEGER">16</col>
  [sqlunit]       <col id="4" type="NUMERIC">56.00</col (3)
  [sqlunit]       <col id="5" type="NUMERIC">880.00</col>
  [sqlunit]     </row>
  [sqlunit]   </resultset>
  [sqlunit] </result>
  [sqlunit] *** but got: (4)
  [sqlunit] <result>
  [sqlunit]   <resultset id="1">
  [sqlunit]     <row id="1">
  [sqlunit]       <col id="1" type="VARCHAR">Information Technology</col>
  [sqlunit]       <col id="2" type="VARCHAR">Dick Tracy</col>
  [sqlunit]       <col id="3" type="INTEGER">13</col>
  [sqlunit]       <col id="4" type="NUMERIC">50.00</col>
  [sqlunit]       <col id="5" type="NUMERIC">650.00</col>
  [sqlunit]     </row>
  [sqlunit]     <row id="2">
  [sqlunit]       <col id="1" type="VARCHAR">Information Technology</col>
  [sqlunit]       <col id="2" type="VARCHAR">John Doe</col>
  [sqlunit]       <col id="3" type="INTEGER">16</col>
  [sqlunit]       <col id="4" type="NUMERIC">55.00</col> (5)
  [sqlunit]       <col id="5" type="NUMERIC">880.00</col>
  [sqlunit]     </row>
  [sqlunit]   </resultset>
  [sqlunit] </result>
  [sqlunit] Tearing down test...
  [sqlunit] .
  [sqlunit] Time: 1.204
  [sqlunit]
  [sqlunit] OK (1 tests)
  [sqlunit]

BUILD SUCCESSFUL

Total time: 2 seconds
(1)
The error message says that there is a difference in resultsetId = 1, rowId = 2, colId = 4
(2)
This is what the test expected. This is supplied to SQLUnit by the test author in the XML file.
(4)
This is the result object that SQLUnit generated by running the SQL or stored procedure.
(3)
This is the place in the expected result where the difference was detected.
(5)
This is the place in the generated result which is different from the expected result. This looks like a simple typo, so our corrective action would be to correct the test specification. Other kinds of errors may require us to fix the stored procedure code and re-run the test.