Skip to content
Sharp

Project Structure · interview question

How does mocking help in unit testing an e-commerce application's payment service?

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

Correct answer

C. By simulating payment gateways and removing external dependencies

Why

Mocking allows you to replace real payment gateways with simulated versions, isolating the unit of code under test from external dependencies. This ensures tests are faster and more reliable.

Test yourself on Project Structure

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

Start free test
All Project Structure questions →