Skip to content
Sharp

Testing · interview question

Why do teams use Mockito to mock a dependency in a Java test in production code?

Multiple choiceEasychapter-10-curatedpremiumtestingmocking-with-mockito
Choose one answer
Answer and explanation

Correct answer

C. To isolate the unit of work from external dependencies

Why

Mockito is used to create mock objects for dependencies so that you can test a unit of code in isolation from its dependencies. This helps in verifying the behavior of the unit without relying on the actual implementation of its dependencies.

Test yourself on Testing

A free test with instant, explained results. No account needed.

Start free test
All Testing questions →