-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Sql annotation on tests makes schema.sql executed twice #7416
Labels
status: duplicate
A duplicate of another issue
Comments
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged
label
Nov 18, 2016
philwebb
added
type: bug
A general bug
for: team-attention
An issue we'd like other members of the team to review
and removed
status: waiting-for-triage
An issue we've not yet triaged
labels
Dec 16, 2016
The problem doesn't occur with Spring Boot 1.4.3 because the two contexts no longer share an in-memory database. However, we believe that there shouldn't be two contexts in the first place as the SQL specified in |
wilkinsona
added
status: duplicate
A duplicate of another issue
and removed
for: team-attention
An issue we'd like other members of the team to review
type: bug
A general bug
labels
Jan 11, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
anddata.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 betweenSchemaTwice3Test
run and other tests run. If add (uncomment)@Sql
annotation to theSchemaTwice3Test
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 andorg.springframework.boot.autoconfigure.jdbc.DataSourceInitializer
.The text was updated successfully, but these errors were encountered: