6/5/2023 0 Comments Kotlin uuid![]() ![]() Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container. Use Testcontainers to build a Docker container with the same database you use in production.For example: If you have a table named User, with H2 it will run perfectly, but with PostgreSQL, it will fail, since User is a keyword. But it doesn't really test in all ways your database layer, because it doesn't use the same drivers and keywords of your production database. Use the to instance an H2 memory database, which will die by the end of the test.This option requires a database infrastructure to maintain, resulting in more costs. Access a different database that exists only for test purposes.But how could I access the database to perform a test? Here are some options: Integration tests need to pass through all the flow, beginning at the controller layer and ending at the database layer. When I started to implement tests with Spring Boot, I struggled to find a way to implement integration tests. ![]()
0 Comments
Leave a Reply. |