SQLUnit User Guide | ||
---|---|---|
<<< Previous | Next >>> |
Prior to version 4.0, SQLUnit only allowed for matching two results for equality, or for matching specific columns using a matching criterion defined by one or more MatchPattern objects. SQLUnit now allows the caller to specify an assertion that should be satisfied for a given test as an attribute of the test, diff and batchtest tags. The change is backward compatible, so if the assert attribute is not specified, it defaults to "equal" in case of diff and test, and "batch-equal" in case of batchtest. Both these default assert attributes are actually macro-assertions, and are composed of a comma-separated series of assertions. These assertions, along with some new ones, can be specified either individually or in a sequence that makes sense in the context of the test case.
The assertions that are currently supported by SQLUnit are shown below:
Table 1. SQLUnit Assertions
Assert-String | Description | Used In |
---|---|---|
none | Asserts nothing about the generated and the actual results. This is typically used to disable assertions for the particular test. | diff,test |
equal | Asserts that the two results are equal. This is actually a macro assertion, which resolves to a number of subassertions, which are asserted serially. This is the default assert if not specified in a diff or test tag. | diff,test |
not-equal | Asserts that the two results are not equal. This is an inversion of the equals assertion. | diff,test |
exception-matches | Asserts that the two results have identical exceptions. | diff,test |
not-exception | Asserts that the result returned is NOT an exception | diff,test |
number-outparams-equal | Asserts that the two results have the same number of outparam elements. | diff,test |
outparams-equal | Asserts that the outparams in both the results are equal. | diff,test |
update-counts-equal | Asserts that the update counts in the two results are equal. | diff,test |
number-of-resultsets-equal | Asserts that the number of resultsets in the two results are equal. | diff,test |
resultsets-equal | Asserts that the resultsets are equal, or match if the test contains embedded match tags. | diff,test |
resultset-values-equal | Asserts that the columns in the specified and actual resultset have the same values. No assertion is made for types. | diff,test |
resultset-types-equal | Asserts that the columns in the specified and actual resultsets are of the same type. | diff,test |
fail-with-failure | Asserts that the test will fail with the specified error message. | diff,test |
none | Asserts nothing about the generated and the actual batch results. This is typically used to disable assertions for the particular test. | diff,test |
equal | Asserts that the two batchresults are equal. This is a macro assertion, composed of a sequence of assertions, which are executed serially. This is the default assertion if no assert attribute is supplied for the batchtest tag. | batchtest |
not-equal | Asserts that the two batchresults are not equal. This is the inverse of the equal assertion. | batchtest |
failed-at-equal | Asserts that the failed-at attribute of the batchresult tag, if specified, points to the point where the result generated by the batchcall or batchsql actually failed. | batchtest |
expected-count-equal | Asserts that the number of update counts specified in the expected batchresult, either as an expected-count attribute, or listed explicitly, is the same as the one in the generated batchresult. | batchtest |
updatecount-equal | Asserts that the updatecount values are the same for the result specified by batchresult and the result generated by the call to batchsql or batchcall. | batchtest |
fail-with-failure | Asserts that the test will fail with the user-supplied failure message. | batchtest |
<<< Previous | Home | Next >>> |
Extending SQLUnit: Adding support for your own datatypes | Extending SQLUnit: Adding your own Assertion |