# Tests as data: ensuring AI-generated code does what we want

DevFeed: [Tests as data: ensuring AI-generated code does what we want](<https://devfeed.tech/articles/tests-as-data-ensuring-ai-generated-code-does-what-we-want-129846.md>)

Original publisher: [Read original article](<https://martinfowler.com/articles/tests-as-data.html>)

Author: Martin Fowler (martin@martinfowler.com)

Published: 2026-11-11T15:17:00Z

Content type: article

Language: en

Sources: [Martin Fowler](<https://devfeed.tech/sources/martin-fowler.md>)

Topics: [Test automation](<https://devfeed.tech/topics/test-automation.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [mutation-testing](<https://devfeed.tech/topics/mutation-testing.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [3](<https://devfeed.tech/tags/3.md>), [age-of-ai](<https://devfeed.tech/tags/age-of-ai.md>), [agents](<https://devfeed.tech/tags/agents.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [ai-coding](<https://devfeed.tech/tags/ai-coding.md>), [ai-coding-assistants](<https://devfeed.tech/tags/ai-coding-assistants.md>), [ai-generated-code](<https://devfeed.tech/tags/ai-generated-code.md>), [all](<https://devfeed.tech/tags/all.md>), [automated](<https://devfeed.tech/tags/automated.md>), [automated-testing](<https://devfeed.tech/tags/automated-testing.md>), [code](<https://devfeed.tech/tags/code.md>), [coding](<https://devfeed.tech/tags/coding.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [coding-assistants](<https://devfeed.tech/tags/coding-assistants.md>), [data](<https://devfeed.tech/tags/data.md>), [ensuring](<https://devfeed.tech/tags/ensuring.md>), [tests](<https://devfeed.tech/tags/tests.md>), [want](<https://devfeed.tech/tags/want.md>)

## AI overview

When AI agents write both production code and tests, tests can become hard to review, tightly coupled to implementation, and vulnerable to changes that weaken their assurance. The article proposes treating developers as customers of AI-written code and making readable customer tests the main behavioral contract. Store cases as data in text files--tables for simple inputs and outputs, or a domain-specific language for richer scenarios--and use a test runner to execute them. Black-box tests can target the system, services, or focused components; tests need not all run end to end. Keeping test data separate can make unexpected changes easier to spot, though runners and DSLs still need validation. The author recommends checking test effectiveness with mutation testing and validating expected behavior against domain experts, authoritative documents, or alternative implementations. These methods add DSL and runner maintenance, do not alone assure correctness, and should be paired with techniques such as property-based testing and human exploratory testing. The article presents them for production systems, while noting prototypes may prioritize rapid learning.

## Source excerpt

Automated testing in the age of AI coding assistants is problematic: when AI agents write both production and test code, developers risk losing the assurance that automated tests protect against functional errors. Matteo Vaccari makes three claims: (1) when AI writes the code, developers become its customers; (2) therefore customer tests, not developer tests, become the primary contract between humans and AI; (3) moving that contract into test data rather than test code makes it easier to protect it from unexpected modifications by coding agents. All of this optimizes for human-readable tests that establish a contract between humans and AI. While in the past DSL parsers and custom test runners were expensive to write and maintain, now AI makes them cheap. more...