Testing Quiz - Languages Python
Free practice quiz: Testing (Languages Python). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
This Languages Python practice quiz has 52 multiple-choice questions on Testing, and 52 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.
Start quiz: 52 questions, freeSample questions
Which of the following is a common testing framework in Python used for unit testing?
Show answer
Answer: D. All of the above
Python has several popular testing frameworks. 'unittest' is part of the standard library, 'pytest' is a widely adopted third-party framework known for its simplicity and powerful features, and 'Nose' (or Nose2) is another established framework. All three are commonly used for unit testing.
Which of the following is a type of testing that verifies the behavior of individual units of source code?
Show answer
Answer: A. Unit Testing
Unit testing focuses on testing the smallest testable parts of an application, typically functions or methods, in isolation.
In Pytest, how can you run tests that are marked with a specific name?
Show answer
Answer: A. `pytest -m marker_name`
The `-m` flag in Pytest is used to select tests based on their assigned markers. This allows for categorizing and running specific groups of tests.
What is a 'test case'?
Show answer
Answer: A. A set of conditions or variables under which a tester will determine whether a system under test satisfies requirements or works correctly.
A test case is a detailed description of a series of actions, inputs, and expected outputs to verify a specific feature or functionality of the software.
In Pytest, what is the purpose of `pytest.mark.parametrize`?
Show answer
Answer: A. To run a single test function multiple times with different arguments.
`pytest.mark.parametrize` is a decorator used to run a test function with multiple sets of arguments, making it a powerful tool for data-driven testing.
More questions in this quiz
Answers and explanations are in the full quiz.
- What is the primary purpose of a 'mock' object in testing?
- In the context of Python testing, what does the term 'assertion' refer to?
- What is 'test coverage' in software testing?
- Which of the following is NOT a type of testing commonly performed in software development?
- In Pytest, how would you typically mark a test to be skipped?
- What is the purpose of 'parameterized testing'?
- Which Python standard library module provides a framework for writing and running tests?
- What is the main advantage of using 'test-driven development' (TDD)?
- In Pytest, what is a 'fixture' used for?
- What is the purpose of a 'tearDown' method in a test case (common in `unittest`)?
- What does the `assert` statement do in a Python test?
- What is 'integration testing'?
- Which Pytest feature allows you to run a single test function from the command line?
- What is 'monkey patching' in the context of Python testing?
- What is the primary goal of 'regression testing'?
- In Pytest, what is the purpose of `pytest.raises`?
- What is the role of a 'stub' in testing?
- What does the `setUpClass` method in `unittest` do?
- What is the main difference between a stub and a mock object?
- What is the purpose of the `doctest` module in Python?
- In the context of Pytest, what is the purpose of `pytest.skip(reason)`?
- What is the significance of a 'test suite'?
- What is 'property-based testing'?
- Which of the following Pytest fixtures is provided by default to get the current test module's name?
- What is the purpose of a 'test double'?
- What is 'performance testing'?
- What is the primary benefit of using mocking libraries like `unittest.mock` or `pytest-mock`?
- What does the `setUp` method in `unittest` do?
- Which command-line option in Pytest is used to run tests verbosely, showing more details about the test execution?
- What is 'assertion chaining' in the context of testing?
- What is the purpose of a 'test plan'?
- In Pytest, how can you run tests that are decorated with a specific marker, excluding others?
- What is the role of a 'test driver' in testing?
- What is the purpose of `pytest.fixture(scope='session')`?
- What is 'exception testing'?
- What does `pytest.approx()` do?
- What is 'smoke testing'?
- What is the primary difference between 'white-box testing' and 'black-box testing'?
- What does the `--lf` or `--last-failed` flag in Pytest do?
- What is the purpose of a 'test harness'?
- In Pytest, how can you discover tests in subdirectories by default?
- What is 'coverage.py' used for in Python testing?
- What does `pytest.fixture(scope='module')` imply?
- What is 'fuzz testing' or 'fuzzing'?
- What is the primary purpose of a 'test framework'?
- Which of the following is a key characteristic of good unit tests?
- What does the `conftest.py` file in Pytest commonly serve?