Testing, Debugging, Version Control and
Automation Best Practices — Questions &
Answers
1. What is software testing?
A. Writing documentation
B. Deploying code
C. Installing packages
D. Checking that code behaves as expected
Answer: D. Checking that code behaves as expected
Rationale: Quality assurance.
2. What is a unit test?
A. A test of the whole system
B. A test of a single small piece of code, like one function
C. A user survey
D. A load test
Answer: B. A test of a single small piece of code, like one function
Rationale: Smallest unit.
3. What is an integration test?
A. A single-function test
B. A style check
C. A test checking that components work together
D. A user survey
Answer: C. A test checking that components work together
Rationale: Interactions.
4. What module is Python's built-in testing framework?
A. pytest
B. nose
C. unittest
D. testlib
Answer: C. unittest
Rationale: Standard library.
,5. What is pytest?
A. A popular third-party testing framework with simple assert-based tests
B. A built-in module
C. A linter
D. A debugger
Answer: A. A popular third-party testing framework with simple assert-based
tests
Rationale: pip install pytest.
6. How does pytest discover tests by default?
A. Any file
B. Only files named tests.txt
C. Only classes named Test
D. Files named test_*.py or *_test.py with functions starting with test_
Answer: D. Files named test_*.py or *_test.py with functions starting with test_
Rationale: Conventions.
7. What does the assert statement do?
A. Prints a message
B. Raises AssertionError if a condition is false
C. Catches exceptions
D. Defines a test
Answer: B. Raises AssertionError if a condition is false
Rationale: Testing.
8. In unittest, what must test classes inherit from?
A. unittest.TestCase
B. object only
C. Exception
D. Test
Answer: A. unittest.TestCase
Rationale: unittest structure.
9. In unittest, what method name prefix identifies test methods?
A. test_
B. check_
C. run_
D. assert_
Answer: A. test_
Rationale: Naming.
, 10. What does self.assertEqual(a, b) check in unittest?
A. That a equals b
B. That a is b
C. That a is True
D. That a raises an error
Answer: A. That a equals b
Rationale: Assertion.
11. What does assertRaises check?
A. That values are equal
B. That a value is True
C. That a file exists
D. That code raises a specific exception
Answer: D. That code raises a specific exception
Rationale: Exceptions.
12. What are setUp and tearDown methods for?
A. Running only once
B. Preparing and cleaning up before and after each test
C. Deploying code
D. Writing logs
Answer: B. Preparing and cleaning up before and after each test
Rationale: Fixtures.
13. What is a pytest fixture?
A. Reusable setup code provided to tests
B. A test result
C. A bug
D. A log file
Answer: A. Reusable setup code provided to tests
Rationale: @pytest.fixture.
14. What is mocking in tests?
A. Making fun of code
B. Deleting tests
C. Replacing real objects, like network calls, with controlled fake ones
D. Running in production
Answer: C. Replacing real objects, like network calls, with controlled fake ones
Rationale: unittest.mock.
15. Why mock external services in automation tests?
A. To slow tests
B. To use real data
C. It's required
D. To test logic without depending on real servers or networks
Answer: D. To test logic without depending on real servers or networks
Rationale: Isolation.