Description
Sample to reproduce: https://github.com/savinov/spring-boot-schema-twice
spring-boot 1.4.1, spring-data-jpa, hsqldb (for tests). There is schema.sql
and data.sql
in the test resources folder. Four test classese are annotated with @RunWith(SpringRunner.class)
, @DataJpaTest
and @Sql
. One test class (SchemaTwice3Test
) is annotated only with @RunWith(SpringRunner.class)
and @DataJpaTest
.
Run tests: mvn test
The problem is: schema.sql
is executed twice somewhere between SchemaTwice3Test
run and other tests run. If add (uncomment) @Sql
annotation to the SchemaTwice3Test
then there is no problems. If remove (comment) @Sql
annotation from all the test-classes then there is no problems too.
Workarond with spring.datasource.continueOnError=true
makes all the tests pass, but it's not a solution.
It seems that there is some initialization incompartability between @Sql
annotation and org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer
.