Skip to content
Sharp

Project Structure · interview question

Which of the following is a common use of mocking in unit tests?

Multiple choiceEasychapter-10-curatedpremiumproject-structurejava-modules-jpms
Choose one answer
Answer and explanation

Correct answer

D. To isolate the unit under test from its dependencies.

Why

Mocking is used to isolate the unit under test by substituting dependencies with mock objects, allowing the test to focus on the behavior of the unit alone.

Test yourself on Project Structure

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

Start free test
All Project Structure questions →