All jobs / Backend developer / Testing
Backend developer interview question · 0–1 years
A teammate calls their test a unit test, but it starts a database container and an HTTP server. Does the label matter?
The strongest answer
Yes — a unit test exercises one behaviour with no database, network, clock or filesystem, so it is fast and deterministic; what they have is an integration test, which is fine but belongs in a slower stage
Why it works
Exactly — the label sets the expectation: runs on every save, deterministic, and never red because something else was down.
What a good answer covers
- Unit: one behaviour, no I/O.
- Fast and deterministic by definition.
- Integration tests are fine — elsewhere.
- Name the layer honestly.
Answers that fall short
- Close, but not the strongest: It matters because that test will be slow, so I would keep it out of the fast suite
Speed is the visible symptom; the deeper point is determinism, because that test can now fail for reasons unrelated to your code. - Weak: The label is bookkeeping; what counts is that the behaviour is covered somewhere
Coverage is not the only question. The pyramid only works if the fast layer really is fast and reliable. - Red flag: If it passes and it catches bugs, I will call it whatever gets the pull request merged
Vocabulary that bends to get a merge is how a five-minute suite becomes a forty-minute one nobody trusts.
Who gets asked this
More Testing questions
- In a test, what is the difference between a stub, a mock and a fake?
- Your repository tests run against an in-memory database and pass, but the same query fails in production…
- How do you test that POST /orders returns 201 with the right body, without deploying anything?
- A refactor that changed no behaviour broke forty tests. Each one asserts that a particular method was called…
- What would consumer-driven contract tests give you here?
- The service’s CI suite fails about one run in five for reasons unrelated to the change, and the team’s habit…