Wrong table count in DbUnit + springtestdbunit

I have 2 tables, but code from this post leads exception.

What I am doing wrong?

How fix this?

Fail text

junit.framework.ComparisonFailure: table count
Expected :5
Actual   :2

Pom dependencies



<?xml version='1.0' encoding='UTF-8'?>
<table name="CATEGORY">

POST UPDATE (information, requested by people added)


public void save() throws Exception { 



No table counters

@ActiveProfiles("test") @RunWith(SpringJUnit4ClassRunner.class)     
   TransactionalTestExecutionListener.class, DbUnitTestExecutionListener.class, 
public class SpringHsqlTest {//...


The dataset XML clearly shows two tables being created, presumably in a separate unit test database.

Your test code seems to be expecting 2 tables, but it seems that 5 exist - let's see if we can confirm that.

I presume the testTarget object in your save() test method is a Spring repository of some kind. So you should be able to add the following to that repository:

@Query(value = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='TABLE' ", nativeQuery = true) List<String> tableNames();

then in the save() method in the test:

for (String table : testTarget.tableNames()) { System.out.println(table); }

this should cause the list of tables the test method has access to to be printed on the console.

Need Your Help

order mysql query result in decreasing order

mysql sql select join sql-order-by

I am trying to create a table for marks and rank team in decreasing order.