Recall & Review
beginner
What is parallel execution in Continuous Integration (CI)?
Parallel execution in CI means running multiple tests at the same time to save time and get faster feedback on code changes.
Click to reveal answer
beginner
How does pytest support parallel test execution?
Pytest supports parallel test execution using the plugin called
pytest-xdist, which allows tests to run on multiple CPU cores simultaneously.Click to reveal answer
beginner
What is a common command to run pytest tests in parallel using 4 CPUs?
The command is
pytest -n 4, where -n 4 tells pytest to use 4 CPU cores for running tests in parallel.Click to reveal answer
beginner
Why is parallel execution useful in CI pipelines?
It reduces the total test run time, helping developers get quick feedback and merge code faster, improving productivity and code quality.
Click to reveal answer
intermediate
Name one challenge when running tests in parallel in CI.
Tests might interfere with each other if they share resources like files or databases, causing flaky or failing tests.
Click to reveal answer
Which pytest plugin enables parallel test execution?
✗ Incorrect
The pytest-xdist plugin allows tests to run in parallel across multiple CPUs.
What does the command
pytest -n 3 do?✗ Incorrect
The
-n 3 option tells pytest to run tests in parallel using 3 CPU cores.Why might tests fail when run in parallel in CI?
✗ Incorrect
Tests sharing resources like files or databases can interfere with each other when run in parallel.
What is a key benefit of parallel test execution in CI?
✗ Incorrect
Parallel execution speeds up tests, giving developers faster feedback.
Which of these is NOT a good practice for parallel tests?
✗ Incorrect
Sharing global state can cause tests to interfere and fail when run in parallel.
Explain how pytest can run tests in parallel in a CI environment and why this is helpful.
Think about how multiple tests can run at the same time to save time.
You got /5 concepts.
Describe one challenge you might face when running tests in parallel and how to avoid it.
Consider what happens if two tests try to change the same file at once.
You got /4 concepts.