Skip to content
Sharp

Testing · interview question

Why would you mock PaymentGateway when unit testing OrderService?

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

Correct answer

A. To isolate order logic and avoid real network side effects

Why

Mocking the payment boundary keeps the test focused on how OrderService reacts to success or failure. It avoids accidental external calls and keeps the unit test fast and deterministic.

Test yourself on Testing

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

Start free test
All Testing questions →