All jobs / AI engineer / AI Coding & Agentic Development
AI engineer interview question · 1–3 years
You asked an assistant to write unit tests for an existing module. It produced forty tests, all green, and coverage jumped.
What do you check before you trust them?
The strongest answer
That they assert the intended behaviour, not just whatever the code does today — I read the assertions, break the code on purpose to see tests fail, and add the edge cases from the spec
Why it works
Exactly — tests generated from the code tend to lock in its current behaviour, bugs included. A test that cannot fail proves nothing.
What a good answer covers
- A test that cannot fail proves nothing.
- Read the assertions, not the count.
- Break the code; watch a test fail.
- Add the spec’s edge cases yourself.
Answers that fall short
- Close, but not the strongest: I skim the test names to see the main cases are there and look at the coverage report for untested branches
Names and coverage show what ran, not what was checked. The assertions are where generated tests go soft. - Weak: Nothing more; green tests and high coverage are exactly what a test suite is for
Coverage counts executed lines. A test with a weak assertion executes plenty and verifies nothing. - Red flag: If one of them fails later I ask the assistant to fix the test so the build goes green again
Editing the test until it passes turns the suite into a record of whatever the code does, which is the opposite of a test.
Who gets asked this
More AI Coding & Agentic Development questions
- A teammate’s coding agent opens one pull request: 2,400 changed lines across 45 files, mixing a rename, a…
- Your team’s coding agent keeps producing working code that ignores the codebase: a second HTTP client, a new…
- A production incident is traced to agent-written code. The author says the agent wrote it; the reviewer says…
- You want to use coding agents to move about 300 modules off a deprecated internal API. How do you run that so…
- What is the difference between an AI coding assistant and a coding agent, and why does it matter for how you…
- Your coding assistant’s solution imports a library you have never heard of. What do you do before you install…
- You are handing a feature to a coding agent. What goes into the task you write for it?