Testing Quiz - Languages Python
Free practice quiz: Testing (Languages Python). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 52 questions freeSample questions
Which of the following is a common testing framework in Python used for unit testing?
- Pytest
- Nose
- Unittest
- All of the above
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?
- Unit Testing
- Integration Testing
- System Testing
- Acceptance Testing
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?
- `pytest -m marker_name`
- `pytest --select marker_name`
- `pytest mark marker_name`
- `pytest run -m marker_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'?
- A set of conditions or variables under which a tester will determine whether a system under test satisfies requirements or works correctly.
- A framework for executing tests.
- A collection of test suites.
- A tool for reporting test results.
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`?
- To run a single test function multiple times with different arguments.
- To mark a test as belonging to a certain category.
- To skip tests that meet certain criteria.
- To define test fixtures.
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.