Spring Boot Parent - 2.0.5.RELEASE
I have few integration tests in order:
- Test class which uses
@MockBean
annotation for some dependencies therefore I have got@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
on class - Another test class which uses db (let's say making some select using JpaRepository in h2 which is fully managed by spring)
First test passes, but second has got exceptions:
Caused by: org.hibernate.exception.SQLGrammarException: could not prepare statement
Caused by: org.h2.jdbc.JdbcSQLException:
Table "x" not found; SQL statement:
It seems like db is created, but DDL wasn't done.
How can I solve this problem?
For sure I can add in second test an annotation @AutoConfigureTestDatabase
, but I feel it is wrong to add this annotation on every test class which uses db after tests with @DirtiesContext
.