Skip to main content
Tue, Dec 1, 2026
The Compute Ledger

AI Architecture · Security · Guardrails & Governance

Front Page
Architecture & Patterns

Rethinking AI Code Testing: Customer Tests as Primary Contract for Functional Assurance

This approach shifts the testing paradigm for AI-generated code by establishing customer tests as the primary human-AI contract, enhancing functional correctness assurance.

2 min read1 primary source

When AI agents generate both production and test code, the traditional assurance provided by automated tests is compromised. A new methodology proposes treating developers as customers of AI-written code, making customer tests the primary contract. This contract should be embedded in test data, not test code, to protect it from AI modifications and ensure functional correctness.

Key Findings

  • —AI-generated code necessitates a re-evaluation of traditional testing methodologies.
  • —Developers should be considered 'customers' of AI-written code.
  • —'Customer tests' must serve as the primary contract between humans and AI.
  • —Moving test logic into data protects the human-AI contract from AI-driven modifications.

The Challenge of AI-Generated Code Assurance

The proliferation of AI coding assistants introduces a significant challenge to traditional software development practices, particularly in the realm of automated testing. As AI agents become capable of generating both production code and its corresponding test suite, the fundamental assurance that automated tests provide against functional errors is at risk. If the same entity that introduces potential bugs also writes the checks for those bugs, the reliability of the testing process is inherently compromised.

According to Martin Fowler, this issue necessitates a rethinking of testing methodologies. He highlights claims made by Matteo Vaccari, which propose a new framework for ensuring the functional correctness of AI-generated code.

Developers as Customers: A New Contract

The core of this new framework rests on three key assertions:

  1. Developers as Customers: When AI writes the code, human developers transition from being the primary authors to becoming the 'customers' of that AI-generated code. This reframes the relationship, emphasizing the need for clear, verifiable outcomes from the AI's work.
  2. Customer Tests as Primary Contract: Consequently, 'customer tests' — tests that reflect the desired behavior from a user's perspective — must become the primary contract between humans and the AI. These tests define what the human expects the AI's code to achieve, independent of the AI's internal logic.
  3. Test Logic in Data: To protect this critical contract from unexpected modifications by coding agents, the test logic itself should be moved into data rather than remaining embedded in test code. This separation ensures that the AI cannot inadvertently alter the very definitions of correctness it is meant to satisfy.

This approach fundamentally optimizes for human-readable tests. By externalizing the contract into data, it becomes easier for humans to inspect, understand, and validate the expected behavior without delving into potentially complex or opaque AI-generated test code. This separation enhances transparency and maintainability, ensuring that the human intent remains the ultimate source of truth.

Architectural Implications and Enabling Technologies

Historically, creating Domain-Specific Language (DSL) parsers and custom test runners to interpret test data was an expensive and time-consuming endeavor. However, the advent of advanced AI capabilities significantly reduces this barrier. AI can now be leveraged to cheaply generate and maintain these tools, making the 'tests as data' paradigm more accessible and practical for widespread adoption.

From an architectural perspective, implementing this methodology requires a clear separation of concerns:

Architecture & Control FlowSchematic
Human Developer
Defines Requirements
Customer Test Data
Interpreted by
AI-Generated Test Runner
Tests
AI-Generated Production Code
Provides Feedback
AI-Generated Test Runner

This architecture ensures that the human-defined contract, represented by the customer test data, remains distinct and protected. The AI's role shifts from generating the contract to fulfilling it and providing the tools to verify that fulfillment. This enhances the assurance that automated tests provide, even when the underlying code is AI-generated, by establishing an independent and human-centric validation layer.

This shift is crucial for maintaining trust and control in increasingly AI-driven development environments, ensuring that functional correctness is not merely assumed but rigorously verified against human expectations.

Architectural Guardrails & Controls

Open Full Register →

Why It Matters

For enterprise architecture and risk teams, this paradigm shift offers a critical path to maintaining functional correctness and accountability in AI-assisted development. It mitigates the risk of AI introducing subtle errors or vulnerabilities by ensuring human-defined requirements remain the ultimate arbiter of code behavior.

Primary Sources & References (1)

This report was synthesized from the following primary documents.

  1. [1]Tests as data: ensuring AI-generated code does what we want

    Martin Fowler (Architecture)