springtestdbunit / spring-test-dbunit

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

The usage of @ExpectedDatasets is not clear #124

Open rbsrcy opened 8 years ago

rbsrcy commented 8 years ago

@philwebb Hi:

Why do not put the Dataset that declare by @ExpectedDatabase in @ExpectedDatabases togeter,and just verfify onece with after @Test function;

Here is the master code in in com.github.springtestdbunit.DbUnitRunner

private void verifyExpected(DbUnitTestContext testContext, Annotations<ExpectedDatabase> annotations)
                throws Exception {
            if (testContext.getTestException() != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Skipping @DatabaseTest expectation due to test exception "
                            + testContext.getTestException().getClass());
                }
                return;
    }
            DatabaseConnections connections = testContext.getConnections();
            DataSetModifier modifier = getModifier(testContext, annotations);
            boolean override = false;
            for (ExpectedDatabase annotation : annotations.getMethodAnnotations()) {
                    verifyExpected(testContext, connections, modifier, annotation);
                    override |= annotation.override();
            }
            if (!override) {
                    for (ExpectedDatabase annotation : annotations.getClassAnnotations()) {
                            verifyExpected(testContext, connections, modifier, annotation);
                    }
    }
     }