0%
AI-Assisted Coding Interviews: Prompting, Reviewing AI Output, Testing, and Handling the Twist
How AI-Assisted Rounds Work
Prompting the Assistant
Reviewing AI Output
Thinking Out Loud
Time Management
When to Trust the Visible Tests
Every interview codebase comes with some visible tests, and every candidate runs them. The question is what to conclude when they pass. Green visible tests are real evidence: the code handles the cases the authors chose to show you. They are not proof that the code satisfies the rule, and they say nothing at all about the cases they do not cover. Knowing how much to trust them, and where, is a skill in its own right.
This lesson covers what visible tests do and do not tell you, how to map them against the rule, how to spot tests that are weak, wrong or flaky, what to do when a test disagrees with the rule, how to use the suite as a safety net and when to stop adding checks of your own.
Why visible tests exist
Interview codebases include visible tests for several reasons. They show the expected input and output format, so you do not have to guess how the function is called. They give you a quick way to check that the code runs at all. They catch obvious breakage when you make a change. And they let the interviewer see how you use them: whether you run them, read them and build on them.
They are not usually designed to be complete. Interviewers want to see whether you can find what the tests miss, so the visible suite is often deliberately small. It typically covers the happy path and one or two simple variations. Hidden checks, or the interviewer's own questions, cover the rest.
What a green run tells you
A green run tells you that the code produces the expected output for each visible input. It tells you the code compiles and runs, the function signature matches, the output format is right and the main path works. These are valuable facts. A red run on the visible suite is a clear sign that something basic is broken, and fixing it comes first.
A green run does not tell you that the code handles empty input, large input, ties, duplicates, invalid input, boundary values or any case the tests do not include. It does not tell you that the code meets the performance requirement. It does not tell you that the code leaves its inputs unchanged, that repeated calls are independent or that the behaviour matches the rule in cases the authors did not think to show.
Why assistants overvalue green
Assistants are very good at making visible tests pass. When a test fails, they adjust the code until it passes, and they often stop there. Some assistants will even special case an input that appears in a test. A diff that makes all visible tests pass is therefore weaker evidence than it looks, because the visible tests were the target. You need evidence from somewhere the assistant was not aiming.
How interviewers read it
When a candidate says all the tests pass, so I think we are done, the interviewer usually has a follow up ready: what about an empty list? What if two scores tie? What if the input is ten times larger? A candidate who has already asked those questions, and says the visible tests pass, and I have also checked empty input, ties and the size limit, has answered the follow ups before they were asked. That is the difference between relying on visible tests and knowing what they cover.
An example
The rule: return the median of a non empty list of integers; for an even number of elements, return the average of the two middle values.
The visible tests: median of 3, 1, 2 is 2; median of 5 is 5.
Both tests pass. But neither has an even number of elements, which is the rule's second clause. On 1, 2, 3, 4, this returns 3 instead of 2.5. The visible tests were fine as far as they went. They just did not go to the clause where the bug was.
A TypeScript example
The rule: given a list of words, return them grouped by length, with groups sorted by length ascending and words within each group in their original order.
One test, which checks grouping and the order of groups. It cannot detect a sort within groups that happens to match original order here, because aa and cc are already in alphabetical order. An implementation that sorts words alphabetically within each group passes it and breaks the rule on cc, aa.
A Java example
The rule: a method returns the number of business days between two dates, excluding both endpoints and weekends.
The visible test uses a Monday and the following Friday and expects three. An implementation that forgets to exclude weekends passes, because there are no weekends between those dates. The test is correct; its input simply never reaches the weekend clause.
Summary
Visible tests show the format, the main path and that the code runs. They are usually deliberately small, and assistants aim at them. Treat a green run as evidence for the cases it covers and nothing more.
Visible tests in larger codebases
In an AI assisted round, the codebase is often a small application rather than a single function, and the visible tests may cover several modules. Some of those tests protect code you will never touch; others protect the exact functions the task asks you to change. During orientation, find the tests for the area you will work in and run them first, alone. A quick run of the focused tests is faster and easier to read than the whole suite, and it tells you the starting state of the code you care about.
Also note whether the whole suite is green before you start. If some tests already fail, record which ones and why, if it is obvious. Otherwise, you may later think your change broke them. Saying a test was already failing before I touched anything, at the start, avoids a confusing discussion later.
What the test file teaches you
Even when visible tests are incomplete, reading them is one of the fastest ways to understand the code. They show how the function is called, what its inputs look like in practice, what setup it needs and what the authors considered the main cases. Helpers in the test file often show how to build valid input quickly, which saves you time when you write your own tests. A minute reading the test file is usually worth more than a minute reading the implementation.
Tests that were written for the old behaviour
When the task asks you to change behaviour, some visible tests may assert the old behaviour. These are not wrong tests; they are tests for a rule that is about to change. Identify them before you start, so a red test after your change is expected rather than alarming. Update them as part of the change, and say so: this test asserted the old tie order, and the task changes it, so I have updated the expected value.
A sample exchange
Interview Dialogue
The candidate established the baseline, separated pre existing failures from their own work and used the tests as documentation.
The baseline habit
Make the baseline run the first thing you do with any codebase. It costs seconds and it means every later red result has a clear before and after.
A green visible suite tells you the format, the main path and the shown examples are right. It tells you nothing about the clauses, sizes and edge cases the tests do not reach.