DbUnit FAQ

Official DbUnit FAQ from DbUnit website

You can report errors, add precisions or discuss the official FAQ here.
You have an idea for a good FAQ and know the answer? Add it here!

BuildingDbUnit | SupportedRDBMS | PendingDbUnitFaq

See DbUnitSupport if you have a question but don't know the answer!

Note that there is an error in the documentation.
The example shows:

// Fetch database data after executing your code
        IDataSet databaseDataSet = getConnection().createDataSet();
        ITable actualTable = databaseDataSet.getTable("TABLE_NAME");

        // Load expected data from an XML dataset
        IDataSet expectedDataSet = new FlatXmlDataSet(new File("expectedDataSet.xml"));
        ITable expectedTable = expectedDataSet.getTable("TABLE_NAME");

        // Assert actual database table match expected table
        Assertion.assertEquals(expectedTable, expectedTable);

It should show:

// Fetch database data after executing your code
        IDataSet databaseDataSet = getConnection().createDataSet();
        ITable actualTable = databaseDataSet.getTable("TABLE_NAME");

        // Load expected data from an XML dataset
        IDataSet expectedDataSet = new FlatXmlDataSet(new File("expectedDataSet.xml"));
        ITable expectedTable = expectedDataSet.getTable("TABLE_NAME");

        // Assert actual database table match expected table
        // Fixed the assert from the example here to us actualTable.
        Assertion.assertEquals(expectedTable, actualTable );
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License