Recall & Review
beginner
What is the main purpose of using test containers in database testing?
Test containers provide a lightweight, disposable database environment for tests. They help ensure tests run in isolation with a real database instance, improving reliability and consistency.
Click to reveal answer
intermediate
How do test containers improve integration testing in Spring Boot applications?
They start a real database inside a container before tests run, so the application interacts with a real database. This avoids using mocks and catches real issues with SQL and schema.
Click to reveal answer
beginner
Which Java library is commonly used to manage test containers in Spring Boot tests?
The 'Testcontainers' Java library is widely used. It provides easy APIs to start, stop, and configure containers for databases like PostgreSQL, MySQL, and others.
Click to reveal answer
intermediate
What annotation is typically used in Spring Boot tests to integrate test containers with the test lifecycle?
The @Testcontainers annotation is used on the test class to enable automatic startup and shutdown of containers during tests.Click to reveal answer
advanced
Why is it important to configure the datasource URL dynamically when using test containers?
Because the container's database URL, port, and credentials are assigned at runtime, the Spring Boot datasource must be configured dynamically to connect to the running container instance.
Click to reveal answer
What does a test container provide for database testing?
✗ Incorrect
Test containers run a real database inside a container, ensuring tests use an actual database environment.
Which annotation enables automatic container lifecycle management in Spring Boot tests?
✗ Incorrect
@Testcontainers manages starting and stopping containers automatically during tests.
Why must datasource properties be set dynamically when using test containers?
✗ Incorrect
Test containers assign ports and URLs dynamically, so datasource config must adapt to connect correctly.
Which library is commonly used to create and manage test containers in Java?
✗ Incorrect
Testcontainers is the Java library designed for managing containers in tests.
What is a key benefit of using test containers over in-memory databases for testing?
✗ Incorrect
Test containers run real databases, so tests catch issues that in-memory databases might miss.
Explain how test containers help improve database integration testing in Spring Boot.
Think about how a real database inside a container differs from mocks or in-memory databases.
You got /5 concepts.
Describe the steps to set up a PostgreSQL test container in a Spring Boot test class.
Focus on annotations, container declaration, and datasource setup.
You got /5 concepts.