I give you the concrete answer for a Spring boot application: just put a schema.sql or init.sql on your classpath, have Spring use it by setting property: "spring.sql.init.mode=always" => then when your application start up the ApplicationContext with a DatabaseContainer, it makes sure, that the init-scripts are run. If you use another technology, you may have to start the sql-execution in the tests manually - but you can do that, since at test execution time your DB-Container accepts connections when container is properly registered...
TestContainers is absolutely revolutionary given its integration with Java and Spring
Great talk, Oleg 🚀
👍🏻👌
can we build native images into testcontainers?
How to load initial data into database testcontainer if any initial data needs to test?
I give you the concrete answer for a Spring boot application:
just put a schema.sql or init.sql on your classpath, have Spring use it by setting property: "spring.sql.init.mode=always"
=> then when your application start up the ApplicationContext with a DatabaseContainer, it makes sure, that the init-scripts are run.
If you use another technology, you may have to start the sql-execution in the tests manually - but you can do that, since at test execution time your DB-Container accepts connections when container is properly registered...
Docker has the ability to run a script file on initialization.. I don't know if Test Containers can tap into that.