Recall & Review
beginner
What is the main purpose of using test containers with Docker in testing?
Test containers provide isolated, real environment instances (like databases or services) inside Docker containers for reliable and consistent testing.
Click to reveal answer
intermediate
How does pytest integrate with Docker test containers?
Pytest can use fixtures to start and stop Docker containers before and after tests, ensuring tests run against real services in containers.
Click to reveal answer
intermediate
Why is it better to use test containers instead of mocking external services?
Test containers run actual service instances, catching integration issues early, unlike mocks which only simulate behavior and may miss real problems.
Click to reveal answer
beginner
What is a common Python library to manage Docker test containers in pytest?
The 'testcontainers' Python library helps manage Docker containers lifecycle easily within pytest tests.
Click to reveal answer
advanced
Describe a simple pytest fixture to start a PostgreSQL test container using testcontainers.
A pytest fixture can create a PostgreSQLContainer instance, start it before tests, yield connection info, and stop it after tests.
Click to reveal answer
What does a test container provide in software testing?
✗ Incorrect
Test containers run real service instances inside Docker containers for accurate integration testing.
Which pytest feature is commonly used to manage test container lifecycle?
✗ Incorrect
Fixtures in pytest setup and teardown resources like test containers before and after tests.
Why might test containers catch bugs that mocks miss?
✗ Incorrect
Running real services in containers exposes integration issues that mocks might not reveal.
Which Python library helps manage Docker containers in pytest tests?
✗ Incorrect
'testcontainers' library simplifies starting and stopping Docker containers in tests.
What is the correct order of actions in a pytest fixture using testcontainers?
✗ Incorrect
Fixture starts the container, yields resource to test, then stops container after test.
Explain how test containers improve integration testing compared to mocks.
Think about running actual services versus simulating them.
You got /4 concepts.
Describe how you would use pytest fixtures with the testcontainers library to test a database service.
Focus on setup, usage, and teardown steps.
You got /4 concepts.