Reputation: 379
I insert 2 rows in my database during my DBUnit test. I cannot predict in advance the insertion order.
My expected-db.xml file contains something along these lines :
<dataset>
<files file_id="1" file_name="name1" ... />
<files file_id="2" file_name="name2" ... />
</dataset>
My test fails when the file named "name2" is inserted first.
I have tried to exclude the ID column with a column filter. I tried setting the NAME column as a the primary key but was not successful in doing so.
Knowing that the file_name value is unique. Is there a way I can assert the expected values whether the actual order respects my expected database or not ?
Upvotes: 0
Views: 663
Reputation: 379
I used the NON_STRICT_UNORDERED assertion mode
@ExpectedDatabase(value = "expected-db.xml", assertionMode = DatabaseAssertionMode.NON_STRICT_UNORDERED)
and deleted the "file_id" columns in the expected-db.xml file
Upvotes: 1