Passing Visible Tests, Failing Hidden Ones

Topics Covered

Why Visible Tests Are Not Enough

What visible tests are for

What hidden checks tend to cover

Why assistant code overfits

Why candidates stop at green

An example in Python

An example in TypeScript

An example in Java

The pattern in all three

What this lesson does not do

A drill for the gap

How interviewers read a green suite

Summary

Most interview codebases come with a small set of visible tests, and most AI assisted rounds grade the final code against a larger set of checks the candidate does not see. The visible tests are there to show the format and the main behaviour. The hidden checks are there to find out whether the code actually follows the rule. A solution that passes every visible test and fails several hidden ones is one of the most common outcomes in these rounds, and assistant written code makes it more common, not less.

This lesson is about closing that gap without knowing what the hidden checks are. You cannot see them, and you should not try to guess them specifically. What you can do is read the rule carefully, find the parts of it the visible tests do not exercise and test those parts yourself.

Visible tests are a sample. The hidden checks are the rest of the rule.

What visible tests are for

Visible tests in an interview codebase usually do three jobs. They show how to call the code and what shape the output takes. They demonstrate the main behaviour on one or two typical inputs. And they give the candidate a quick way to check that the code runs at all. They are rarely designed to be complete. Including every edge case would make the problem easier than intended, because the tests would tell the candidate exactly what to handle.

That means a green visible suite is evidence of only a few things: the code runs, it has the right interface and it handles typical inputs. It is not evidence that the code follows the rule on every input the rule describes.

What hidden checks tend to cover

Without naming any particular round, hidden checks in coding interviews generally cover the same families of cases a careful engineer would test: empty and minimal inputs, boundaries of every range, repeated or duplicate values, inputs that look like a special case but are not, very large inputs where performance matters, and the specific clauses of the rule that the visible tests skip. None of these is a trick. They are what the rule says, applied to inputs the examples did not show.

Why assistant code overfits

Assistants are good at producing code that matches examples. If the prompt includes the README and the visible tests, the assistant will very likely produce something that passes those tests. It is less reliable at following every clause of a rule that the tests do not demonstrate. It may implement the common interpretation of a rule rather than the specific one stated. It may handle the special case shown in an example with a check that also catches lookalikes. It may skip a clause entirely because no example uses it.

Code fitted to the visible examples can be wrong between and beyond them.

The result is code that fits the visible examples and wanders away from the rule elsewhere. When you run the visible tests and see green, the overfit is invisible. That is why this lesson's habit matters.

Why candidates stop at green

Green tests feel like completion, especially under time pressure. Candidates often see the visible suite pass, say done and move on to the next step or the twist. The assistant contributes to this: it often ends its answer with a confident note that all tests pass. Neither the green bar nor the note is false, but both are incomplete.

The candidates who do well treat a green visible suite as the start of verification, not the end. They ask what the rule says that the visible tests do not check, and they test that. It takes a few minutes and is usually the difference between a solution that looks done and one that is done.

An example in Python

Suppose the rule says a function returns the number of whole days between two ISO dates, where the result is negative if the second date is earlier, and both dates are given in the same time zone. The visible tests check two dates a week apart and two identical dates.

diff
1+def days_between(a, b):
2+    from datetime import date
3+    d1 = date.fromisoformat(a)
4+    d2 = date.fromisoformat(b)
5+    return abs((d2 - d1).days)

Both visible tests pass. But the rule says the result is negative when the second date is earlier, and abs throws that away. No visible test has the second date earlier, so the overfit is invisible. One probe with the dates reversed shows it.

An example in TypeScript

The rule says a slug is a lowercase string of letters, digits and single hyphens, with no hyphen at the start or end. The visible tests check that hello world becomes hello-world and that Hello becomes hello.

diff
+function slugify(s: string): string {
+  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-");
+}

Both pass. But an input with a trailing space or trailing punctuation produces a trailing hyphen, which the rule forbids, and an input that starts with punctuation produces a leading hyphen. The visible tests used inputs with clean ends, so they missed both clauses of the rule.

An example in Java

The rule says a function returns the median of a list of integers, and for an even number of values the median is the mean of the two middle values as a double. The visible tests use lists of three and five values.

diff
1+static double median(List<Integer> xs) {
2+    List<Integer> s = new ArrayList<>(xs);
3+    Collections.sort(s);
4+    return s.get(s.size() / 2);
5+}

Both visible tests pass, because both lists have an odd length. Any list with an even length returns the upper middle value instead of the mean. The rule had a clause the visible tests never touched.

The pattern in all three

In each example, the assistant's code was a natural, common implementation. Each passed the visible tests. Each failed a clause of the rule that the visible tests did not exercise. And in each case, reading the rule clause by clause would have pointed straight at the gap. The rest of this lesson turns that observation into a routine.

What this lesson does not do

This lesson does not try to predict the hidden checks of any particular round, and you should not either. Guessing specific hidden tests leads to code that handles a few guessed cases and still misses the rule. The aim is to test the rule itself, thoroughly enough that whatever the hidden checks are, the code follows it.

A drill for the gap

Take three short problems with a README and visible tests. Before writing or generating any code, list the clauses of each rule and mark which ones the visible tests exercise. Then ask an assistant to solve each problem, run the visible tests and probe every unmarked clause. Count how many of the assistant's solutions fail at least one unmarked clause. Most people are surprised by how high the count is, and the surprise is useful: it makes the habit stick.

How interviewers read a green suite

Interviewers know the visible suite is incomplete; they designed it that way. When a candidate says all tests pass, done, the interviewer hears that the candidate has not yet checked the rule. When a candidate says the visible tests pass, and here are the clauses they do not cover, the interviewer hears that the candidate understands what tests can and cannot tell them. The second response is worth far more, even before any probe is run.

Summary

Visible tests show the format and the typical case. Assistant code fits them easily and misses clauses they skip. Treat green as the start of verification, test the rule rather than guessing hidden tests and make the gap visible to the interviewer.

Green is the start of verification

A green visible suite tells you the code runs, has the right interface and handles typical inputs. It does not tell you the code follows every clause of the rule. Treat green as the point where you start probing the clauses the tests skip.