Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Automation & CISeniorOccasionalIntegration

How would you prevent a fake service or in-memory repository from drifting from the real implementation?

Answer

Define a shared behavioral contract and run the same conformance examples against the fake and the real implementation. Cover schemas, defaults, error semantics, ordering, idempotency and important concurrency behavior; version the contract and run it in CI for both providers. A fake should fail fast on unsupported behavior instead of silently returning convenient results.

Strong answer includes

  • runs one contract suite against fake and real implementations
  • covers failures and state semantics, not only happy paths
  • treats unsupported fake behavior explicitly

Practical example

A team's in-memory repository silently allowed duplicate primary keys while Postgres enforced a unique constraint; a shared contract-test suite that runs against both the fake and the real database catches the mismatch the moment someone adds a test relying on that duplicate-insert behavior.

#test-doubles#contract-testing#ci#automation-engineer

Sources

Use test doubles in AndroidGoogle · Definitions, selection and limitations of dummies, stubs, spies, mocks and fakesOpenAPI Specification 3.2.0OpenAPI Initiative · API contracts, schemas and operation descriptions