3

We are in the process of analyzing DBUnit for data driven unit testing. We were able to export oracle DB tables to a flat xml dataset using the code below and use the generated dataset as an input to our junit testing.

    // partial database export

    QueryDataSet partialDataSet = new QueryDataSet(connection);
    partialDataSet.addTable("FOO", "SELECT * FROM TABLE WHERE COL='VALUE'");
    partialDataSet.addTable("BAR");
    FlatXmlDataSet.write(partialDataSet, new FileOutputStream("partial.xml"));

org.dbunit.database.QueryDataSet provides option to add tables but not Sequences. We need to export the sequence also the same way to DBUnit Dataset. Is there a way to achieve this ?

We are looking for tools for unit testing (data driven) the Repository layer using open source tools. Is there any other open source tool similar to DBUnit ?

shatk
  • 465
  • 5
  • 16
  • it's not clear what you mean by "export the sequence". are you looking for a way to create the sequence in the database before the test? – Nathan Hughes Mar 10 '14 at 19:55
  • Our agenda is to schedule jenkins to run all junit test weekly and we don't need to run the same against our development DB (oracle). So we are planning to use DBUnit which provides an option to export the DB tables to an xml and run the test by passing the generated XML. (eg: @DatabaseSetup("egsXMLDB.xml") ) . DBunit in turn uses hsql db to do the DB Operation. All test related to DB Tables works fine. However the JPA Query involving Sequence are getting failed. – shatk Mar 11 '14 at 05:16

0 Answers0