2026年10月20日

When Are Tests Enough When Programming with AI? Never

When Are Tests Enough When Programming with AI? Never

AI can generate thousands of lines of code in minutes. But who is going to verify that every one of those lines actually works?

Never.

There is a question that keeps coming up as AI becomes increasingly involved in software development: when have we written enough tests?

My answer is simple: never. And with AI-generated code, that answer gets more relevant every day.

AI has changed the speed of development, not the need for correctness

Writing code is no longer the most time-consuming part of software development. AI coding assistants generate functions, APIs, database migrations, infrastructure configurations, and whole applications at extraordinary speed. What used to take days can now take hours. Sometimes minutes.

The problem is the other half of the equation. AI generates code much faster than humans can understand, review, and validate it, and that creates an imbalance. The faster we generate, the faster we can introduce bugs, security vulnerabilities, incorrect assumptions, and unexpected behavior. AI does not remove software defects. It removes the friction that used to slow their arrival.

Worse, AI-generated code usually looks convincing. It is clean, structured, well-commented, apparently logical. Until it runs in production.

Every line of code is a potential failure

Every meaningful line of AI-generated code should be exercised by automated tests. Not just the critical functions. Not just the happy paths. Not just the scenarios the AI happened to anticipate. Every line, every branch, every condition, every exception.

One test per literal line is not a practical testing strategy. A single test can exercise many lines, and full line coverage does not guarantee correctness. But the bar should sit above conventional coverage: we need to verify what the code does, not merely confirm that it executed.

Consider a payment function. It works with valid inputs. What happens when the network fails halfway through, the same request is submitted twice, the transaction is interrupted, a response carries unexpected data, two requests arrive at once, or the API returns an error nobody planned for?

Ten passing tests do not cover the eleventh scenario. Tests demonstrate the behavior that has been checked. They do not prove the absence of defects nobody imagined.

Tests must run every time

Automated tests cannot be something you run occasionally. Not at the end of the sprint, not before a major release, not when we remember. With AI-assisted development, automated tests run continuously. Every meaningful code change triggers the relevant tests, with the full regression suite running at defined integration and release gates.

The reason is blast radius. A small AI-generated change can reach far beyond the function it modifies. An agent may fix a bug in one module while breaking three others, update a dependency, modify a shared interface, or change a database query in a way that affects an unrelated feature.

When an agent reports "Implementation complete. All requested changes have been made", that sentence carries almost no information about correctness. Code completion is not validation. A task is complete when the required behavior has been independently verified against meaningful, automated checks. And even then it is only verified against the failures those checks can detect.

The endless testing cycle

The more tests we write, the more edge cases we discover. The more edge cases we discover, the more code we modify. The more code we modify, the more tests we need. Then we start again. There is no natural endpoint, and AI makes the cycle tighter because it removes most of the friction involved in producing code.

An agent can generate 500 lines of code, another agent can generate the tests, and a third can review both. But who verifies that the tests are correct? If the same flawed assumption sits in both the implementation and its tests, the code passes, the suite is green, and the bug stays. That is the most important limitation of AI testing its own work: an AI-generated test can validate an AI-generated mistake.

Independent verification, adversarial test generation, mutation testing, property-based testing, integration testing, and real-world behavioral validation are the counterweight. Even then, absolute certainty stays out of reach.

A green test suite is not proof of correctness

A green build pipeline is comforting. All tests passed. Coverage: 100%. No reported failures. It feels like success.

But 100% coverage only means the code executed under the conditions the tests represent. It does not mean the code behaves correctly under every condition. It does not mean the application is secure, that concurrent operations are safe, or that the system will handle production traffic. A system can have perfect line coverage and still be fundamentally wrong. Coverage measures what we exercised, not what we understood.

So the real question is not how many tests we have. It is how many ways our software can fail that we have not considered yet.

AI should generate more tests than code

We should stop measuring AI productivity by how much code it produces and start measuring it by how much verified functionality it delivers. A hundred lines of reliable, thoroughly tested code is worth more than five thousand lines of unverified implementation.

The bigger opportunity is AI as a relentless testing partner: it should try to break the software it creates, challenge assumptions, generate adversarial inputs, explore edge cases, simulate failures, and question whether the existing tests are enough. Then repeat after every change. Generate, test, break, fix, retest, repeat. The goal is not more tests for their own sake. The goal is to find failures before users find them.

The economics of AI development are changing

AI reduces the cost of producing code. It does not automatically reduce the cost of proving that code is reliable. As generation gets cheaper, verification becomes the dominant cost of software development. Generating an application could take an hour while building confidence in its correctness takes weeks.

That is not a surprise. Writing software and proving its reliability are different activities: one creates possibilities, the other systematically eliminates unacceptable failures. The faster AI creates possibilities, the larger the verification burden gets.

Which means testing infrastructure, continuous integration, reproducible environments, observability, and automated security checks are no longer secondary concerns. They are the foundation of AI-assisted development.

So when are tests enough?

Practically, we can establish acceptable risk for a release. We can define quality gates, required coverage, security thresholds, performance requirements, and the business-critical scenarios that must pass. We can decide a system is sufficiently tested to deploy. That is a release decision, not proof that testing is finished.

There is always another edge case, another dependency update, another unexpected input, another production scenario nobody anticipated, another AI-generated modification that changes something we thought was stable. No final test proves we will never need another test.

The code may be finished. The testing never is

AI changed how quickly we can build software. It did not change the fundamental challenge of software engineering: making sure that what we build actually works. If anything, it made that challenge more urgent.

The rules I work by are simple. Every meaningful piece of code gets tested. Every relevant change triggers automated verification. Every discovered bug becomes a regression test. Every passing suite counts as evidence of confidence, not a certificate of perfection.

Never trust code because an AI wrote it. Never trust tests because an AI generated them. The future of AI-assisted programming is not only about generating code faster. It is about verifying that code continuously, independently, and rigorously.

When somebody asks how many tests are enough, my answer stays the same: never enough to stop testing. In software engineering, especially with AI, there is always one more thing that can go wrong.


#ArtificialIntelligence #SoftwareEngineering #AITesting #AICoding #DevOps #ContinuousTesting #SoftwareQuality #TestAutomation