In the context of testing, what is the main difference between a mock and a stub?
- Stubs are used for functions, while mocks are used for objects
- Mocks record and verify interactions, while stubs only simulate behavior
- Stubs are only used in integration tests, while mocks are used in unit tests
- Mocks are less flexible than stubs
The primary difference between a mock and a stub is that mocks record and verify interactions between the code under test and the dependencies, whereas stubs only simulate the behavior of dependencies. Mocks are used to ensure that specific interactions occur as expected, while stubs focus on controlling the response of functions or methods.
Loading...
Related Quiz
- When designing schemas for large-scale systems, the principle of ________ involves dividing the dataset into smaller, more manageable parts.
- While working on a project, you are required to extract specific properties from objects and assign them to variables. How would you utilize destructuring assignment to efficiently accomplish this task, and what would you do to handle non-existent properties?
- The fs.createReadStream method is particularly useful when dealing with ______ sized files.
- Which of the following is the primary role of middleware in Express.js?
- You are developing a system with stringent data integrity requirements. How would you design the schema to enforce data integrity constraints and handle violations effectively?