Search code examples
javaintegration-testingdbunit

FlatXmlDataSet empty table (DBUnit)


Is it possible to validate that the database has no rows for a specific table with a flat xml structure? Something like:

<dataset>
   <TABLE/>
</dataset

but that isn't working because, I think, it only validates if the 'TABLE' exists..

I'm testing a delete..


Solution

  • Currently, I have the same issue and I found the workaround. You can set all fields non-Required and your .xml file will be looking like

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE dataset SYSTEM "dbschema.dtd">
    <dataset>
        <NameOfYourTable/>
    </dataset>
    

    I hope it will help other people.