JDD 2022: Andrés Torres Garcia - Friends don't let friends test with In-Memory databases

youtube.com 1 rok temu


If you have always written code that tests database interactions, specified as data access objects, you very possibly have run up against 1 of the most perennial annoyances in testing: In order to accurately test these interactions, a database is required.

In-memory databases, shared databases instances or investigating in production-like environments are common approaches but all of them have drawbacks: inaccuracy, can't run in parallel or money.

On top of that:
- My company supports 3 database vendors (and versions): MySQL, Oracle and SQL Server
- My company supports SQL Scripts for database creation and upgrades
- My company supports Liquibase for database creation and upgrades

Multiple combinations to test, how do we test all that?

TestContainers to the rescue!
Testcontainers is simply 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.

Testcontainers make the following kinds of tests easier:
Data access layer integration tests: usage a containerized instance of a MySQL, PostgreSQL or Oracle database to test your data access layer code for complete compatibility, but without requiring complex setup on developers' machines and safe in the cognition that your tests will always start with a known DB state. Any another database kind that can be containerized can besides be used.

During the presentation, we will see how we can save time and money during the validation of the data layer against multiple databases, how to easy add fresh versions or fresh vendors and validate them with no code changes, or compose fresh tests, and even how to produce database documentation in an automated way.

We will show a sneak peek of what TestContainers's SaaS solution, Atomic Jar offers to decision our investigating to the cloud.

Website: https://jdd.org.pl
Facebook: https://www.facebook.com/JDDconf
Twitter: https://twitter.com/JDD_Krakow