Search code examples
javatestingjunitdbunitxmldataset

IDataSet manipulation in DBunit


I use IDataSet to read from a XML file and write to my database so I can run the Junit test against my database. problem is my senario is becoming to complicated and I need to change the data in the database in middle of test.

I was looking for a way to change the IDataSet data without reading from XML file and write to database, this way I don't have to create couple of huge XML files just to change one row!

my code currently is something like this

IDataSet dataSet  = new XmlDataSet(fileStream);
DatabaseOperation.CLEAN_INSERT.execute(jdbcConnection, dataSet);

thanks a lot in advance


Solution

  • I'm going to try

    ReplacementDataSet rds = new ReplacementDataSet(ds);
    
    rds.addReplacementObject(John, Tom );
    

    I guess if a fields be unique it's going to work!