springtestdbunit / spring-test-dbunit

Integration between the Spring testing framework and DBUnit
http://springtestdbunit.github.com/spring-test-dbunit/
Apache License 2.0
476 stars 238 forks source link

@DatabaseSetup annotation stopped working in v. 1.3.0 when class inheritance is used #113

Open andrei-l opened 8 years ago

andrei-l commented 8 years ago

When DatabaseSetup annotation is specified on the parent class it is not longer applicable for the child class, meaning that DB setup is not being performed.

E.g.

@DatabaseSetup(connection = "dbConnection", value = "classpath:/SomeDataSet.xml")
abstract class SomeParentTest {
}
class SomeTest extends SomeParentTest {
     @Test
    public void testStuff() throws Exception {
    ....
    }
}

This worked fine in v. 1.2.1.

Attached are completely two same examples with the only difference in spring-test-dbunit version. One works fine, another does not.

spring-test-dbunit-issue-works-v1.2.1.zip

spring-test-dbunit-issue-does-not-work-v1.3.0.zip

ppodgorsek commented 7 years ago

More generally, it would be good for the datasets to be imported in the order of the class hierarchy. For example:

@DatabaseSetup("classpath:/generic-dataset.xml")
public abstract class GenericParentTest {
}

@DatabaseSetup("classpath:/extended-dataset.xml")
public class ExtendedTest extends GenericParentTest {
    @Test
    public void testStuff() throws Exception {
        ...
    }
}

In this example, it would be good to ensure generic-dataset.xml is loaded before extended-dataset.xml.