RoundPi
RoundPi

Reputation: 5947

DbUnit - how to setup multiple initial test status(xml) under one DBTestCase

It's easy to setup a initial status via

@Override
protected IDataSet getDataSet() throws Exception {
    IDataSet data = new FlatXmlDataSetBuilder().build(new File("src/test/resources/my-init1.xml"));
    return data;
}

But if I have a few test cases with under one DBTestCase ? How should I setup multiple initial status (with a few different initial xml files like my-init1.xml, my-init2.xml and my-init3.xml) ?

Thanks in advance !

Upvotes: 3

Views: 2272

Answers (1)

wenic
wenic

Reputation: 1189

Hi I think you might looking to make a CompositeDataSet

http://www.dbunit.org/apidocs/org/dbunit/dataset/CompositeDataSet.html

So it probably look something like...

@Override
protected IDataSet getDataSet() throws Exception {
  IDataSet[] datasets = new IDataSet[] {
     new FlatXmlDataSetBuilder().build(new File("src/test/resources/my-init1.xml")),
     new FlatXmlDataSetBuilder().build(new File("src/test/resources/my-init2.xml")),
     new FlatXmlDataSetBuilder().build(new File("src/test/resources/my-init3.xml"))
  }

  return new CompositeDataSet(datasets);

}

Upvotes: 4

Related Questions