Intermediate Web & Software Development
Q64 / 100

When writing unit tests, what is the main purpose of using mocks and stubs for external dependencies?

Correct! Well done.

Incorrect.

The correct answer is A) To replace real collaborators (databases, APIs, file systems) with controlled fakes so the test runs fast, deterministically, and in isolation from things you don't control

A

Correct Answer

To replace real collaborators (databases, APIs, file systems) with controlled fakes so the test runs fast, deterministically, and in isolation from things you don't control

Explanation

Mocks and stubs stand in for slow or unpredictable collaborators (a payment gateway, a database) so a unit test can verify behavior in isolation, run quickly, and produce the same result every time it runs.

Progress
64/100