0
0
PyTesttesting~5 mins

Docker-based test execution in PyTest - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main benefit of running tests inside a Docker container?
Running tests inside a Docker container ensures a consistent environment, so tests behave the same way on any machine.
Click to reveal answer
beginner
How do you specify the command to run pytest inside a Docker container?
You specify the command in the Dockerfile or docker-compose.yml using CMD ["pytest"] or by passing it in docker run.
Click to reveal answer
intermediate
Why is it important to mount your test code directory as a volume in Docker when running tests?
Mounting your test code as a volume lets Docker use the latest code without rebuilding the image every time you change tests.
Click to reveal answer
beginner
What is a common way to install pytest and dependencies inside a Docker container?
Use a requirements.txt file and add RUN pip install -r requirements.txt in the Dockerfile.
Click to reveal answer
beginner
How can you view test results when running pytest inside Docker?
Test results appear in the Docker container's output logs, which you can see by running docker logs [container_id] or directly in the terminal if you run interactively.
Click to reveal answer
What command runs pytest tests inside a Docker container?
Adocker run myimage pytest
Bdocker build pytest
Cdocker start pytest
Ddocker stop pytest
Why use Docker volumes when running tests?
ATo increase container memory
BTo speed up Docker image building
CTo share test code between host and container without rebuilding
DTo run tests faster on the host
Where should you install pytest in a Docker setup?
AInside the Dockerfile using pip
BOn the host machine only
CAfter running tests
DIn the docker-compose.yml file
How do you see test output when running pytest in Docker interactively?
AOutput is sent to Docker Hub
BOutput is saved in a file only
COutput is hidden by default
DOutput shows directly in the terminal
What is the purpose of a Dockerfile in test execution?
ATo store test results
BTo define the environment and commands to run tests
CTo write test cases
DTo manage test reports
Explain how Docker helps create a consistent test environment for pytest.
Think about how Docker packages everything needed for tests.
You got /4 concepts.
    Describe the steps to run pytest tests inside a Docker container using a Dockerfile.
    Consider what a Dockerfile needs to prepare and how to execute tests.
    You got /4 concepts.