Testing Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
What does the command pytest -v do?
Answer: Option B
Explanation: The -v flag stands for verbose mode.
Q12
What is the output if all assert statements pass in a test file?
Answer: Option C
Explanation: pytest or unittest usually prints "OK" if all pass.
Q13
What does assertTrue() in unittest check?
Answer: Option C
Explanation: It fails if the given expression evaluates to False.
Q14
Which method is used to perform cleanup after each test in unittest?
Answer: Option A
Explanation: It is executed right after each test case.
Q15
What is the default behavior when an assert fails in pytest?
Answer: Option C
Explanation: pytest halts failed tests and reports them.
Q16
What is mock used for in testing?
Answer: Option B
Explanation: It helps isolate the code being tested.
Q17
When using pytest.raises, you generally test for what?
Answer: Option C
Explanation: It ensures that a function raises a specific error.
Q18
What is the output of assert "a" in "apple"?
Answer: Option B
Explanation: The substring "a" exists in "apple".
Q19
Which command runs all tests in the current directory using pytest?
Answer: Option A
Explanation: The dot indicates the current directory.
Q20
What is test coverage in testing?
Answer: Option B
Explanation: Coverage helps to measure testing completeness.