A test suite can lie with perfect formatting. It can pass quickly, cover many files, and still be unable to detect the regression it claims to guard. The test is not useful because it exists. It is useful because it can fail for the right reason.
AI-generated tests are especially prone to the weak form: assert that a function returns something, assert that a component renders, assert that no exception is thrown. Those checks create activity without a behavioral contract. They protect the confidence report, not the product.
The right reason test
For every new test, ask what bug would make it fail. If the answer is vague, the test is vague. A validation test should fail when invalid input is accepted. An auth test should fail when an unauthorized user reaches protected data. A workflow test should fail when the required state transition does not happen.
The quick anti-gaming check is simple: remove or comment out the implementation behavior and run the test. If the test stays green, it was not guarding that behavior. It was decoration.
Prefer real boundaries
Mocks have a place. They are appropriate at true external boundaries: payment providers, email providers, third-party APIs. They are dangerous when they replace the code path you are trying to prove. A mocked database query cannot prove tenant isolation. A mocked router cannot prove middleware order. A mocked schema cannot prove the migration applied.
- Unit tests should pin decision logic and edge cases.
- Acceptance tests should map each criterion to a behavior assertion.
- Integration tests should prove wiring across auth, tenant context, persistence, and routes.
- Regression tests should fail before the fix and pass after it.
Coverage is a map, not a medal
The useful output is an acceptance-criteria coverage table: criterion, test name, status, and gap. That makes missing proof visible. If an acceptance criterion cannot be tested today, say so and track it. Silent skipping is how teams accumulate green dashboards over unproven behavior.
The point is not more tests. The point is fewer claims without tests that can actually say no.
Series linkage
Part 7 of 10 in Prompt Library to Operating System. Debugging creates the reproduction; testing keeps the same failure from returning.
About AmanERP
AmanERP is built for business records that need to be correct, so tests are judged by the failures they can catch, not by the comfort they provide.
