Skip to content
BENIBIX Learn

Mock vs Mock Server

A mock is a fake object inside one test, in the same program. A mock server is a fake API that runs on its own, over the network. Many tests and apps can call the same mock server.

Development🧪 Testing & Quality

Mock (Testing)

A fake part that records how your code called it, so a test can check.

A mock is a test double that records how it was called, so the test can check it. You hand it to your code in place of the real part. After the code runs, you ask the mock: were you called, how many times, and with what? That lets you test that your code sent an email without sending one. Most test tools have mocks built in.

Example
Emma's test gives her sign-up code a mock email sender. The test then checks the mock was called once, with emma@example.com.
Why it matters
Some results never come back as a value, like an email sent. A mock lets you check them anyway.
Full entry
Development🔌 APIs

Mock Server

A fake API that sends back set answers, for building and testing.

A mock server is a fake API that sends back set answers. It copies the real API's endpoints and replies. Front-end teams use one to build before the real API exists. Tests use one so they do not hit a slow or costly real service. It can also fake errors that are hard to cause for real.

Example
Jack's app team builds the checkout screen against a mock server. The real payments API is not ready for two weeks.
Why it matters
Teams stop waiting on each other. Tests stop needing outside services.
Full entry

In one line

Mock (Testing)
A fake part that records how your code called it, so a test can check.
Mock Server
A fake API that sends back set answers, for building and testing.