I have a table with 2 rows and 34 columns. 3 of the columns should be null. When using assertionMode = NON-STRICT
, I can specify 34-3=31 columns in my after.xml file, and DBUnit will realize that the 3 missing columns are supposed to be null. DBUnit ensures that the 2 rows and 34 columns in the table precisely match the 2 rows and 31 columns in my after.xml, and any columns I did not specify in after.xml (3 columns) will be assumed to be null which DBUnit verifies as well.
NON_STRICT no longer works, though, if I want to ensure that I have exactly 2 rows, no more no less (for example, if the table does have the 2 rows specified in the after.xml, it will pass the test regardless of if I have more rows or not).
So, I figured I should use assertionMode = DEFAULT
. When I do this, the error I get is something like "expected columns is 34, but found 31 in table". It only found 31 because I only specified 31 in my after.xml. The other 3 are null, so I left them out of the after.xml per DBUnit docs. DEFAULT seems to make DBUnit expect 34 columns to be specified in my after.xml regardless of if they're null or not, am I missing something?
I have tried roundabout methods, like specifying a query to get me the 31 columns rather than the 34 (3 columns are null) and using the results of that query to compare to my after.xml. I have also just counted up the number of rows and ensured that I have 2 rows. But those seem to be roundabout methods.
Is there a way to specify columns as null in DBUnit other than leaving them out in my after.xml since DEFAULT doesn't seem to like that?
What is the proper way to specify columns as null in DBUnit with assertionMode = DEFAULT?