CS FundamentalsHardTCS NQT · Infosys interview pattern

In a unit test, the real payment gateway is replaced by an object that records calls so that the test can assert “charge() was called exactly once with ₹500”. What kind of test double is this?

  1. A. Mock
  2. B. Stub
  3. C. Dummy
  4. D. Fake

Correct answer: A. Mock

A mock verifies interactions — which calls were made and with what arguments. A stub only returns canned answers, a dummy is passed around but never used, and a fake is a working lightweight implementation (such as an in-memory database).

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic