I'm using JUnit to test my application and everything works fine as long as the database has been initialised before the testing (using
The above answers all use the .sql schema loading technique where I'd have to have a .sql schema for tests. I didn't want to do it that way as my schema would be expanding and I'd rather not go through the hassle of adding entries to the schema as my tests expand.
As I'm using Spring Boot, I came across this annotation which seems to solve the issue by first running
bootRun and then running the tests.
In my test annotations I replaced the
@SpringApplicationConfiguration and left all the classes to be the same. This seemed to solve the issue. So now the
test task invokes bootRun to load the classes and then runs the tests.
Hop this helps anyone facing the same issue.