Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programatically load database setup & compare with expected database in DBUnit

I annotate my test methods like this:

@Test
@DatabaseSetup("/default_database_data.xml")
@ExpectedDatabase(value = "/expected_database_1.xml", assertionMode = NON_STRICT)

is it possible to manually perform the things that @DatabaseSetup and @ExpectedDatabase does:

@Test
public void test(){
  // DBUnit.setup("/default_database_data.xml");
  dao.insert(...);
  // DBUnit.expected("/expected_database_1.xml");
}

I made the syntax up, just to give you an idea of what I need: perform 2 setups and assertions in one unit test.

like image 694
Roay Spol Avatar asked Jun 04 '26 09:06

Roay Spol


1 Answers

two things that might work, check this link.

Link

And also this annotation:

  @DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
like image 181
Eugene Avatar answered Jun 06 '26 00:06

Eugene