Back to all posts
• 7 min read

The Importance of Tests in Agentic Engineering

Why a balanced test pyramid, behavior-driven unit tests against stable facades, and reviewing "golden" acceptance tests let you ship large agentic pull requests with confidence.

From the beginning of agentic engineering, it has been clear that a tight verification loop is essential. Yet when I observe how people build agentic workflows today, many overlook the good old idea of the test pyramid: finding the balanced trade-off between End-to-End (E2E) tests, integration tests, and unit tests.

When coding agents are left to verify their work solely through E2E frontend tests (for example, Playwright), teams sooner or later run into the exact same traps we saw before the agentic era:

  • Slow Continuous Integration (CI) runs and feedback loops
  • Flaky tests
  • Fragile test suites

This slows agents down just as it slowed down humans, simply on another scale. Because agents dramatically scale up the amount of code and features produced, a slow and brittle verification loop quickly becomes a major bottleneck in agentic engineering.


Balancing the Test Pyramid in Agentic Workflows

Each layer of the test pyramid plays a distinct role in giving coding agents fast, reliable feedback:

  • Unit tests focus on smaller parts of the system, where behavior can be tested across different combinations quickly to build high confidence.
  • Integration tests ensure that isolated components and boundaries work together as expected. Here I also see contract testing.
  • End-to-End (E2E) tests provide real use-case coverage from start to finish, but they remain costly and fragile, just as we saw in the pre-agentic era.

The role of the human engineer is to carefully design and balance these tests to get the right trade-off between coverage, speed, and maintainability.

What is a unit test?

When following Kent Beck’s Test-Driven Development (TDD) style, a unit test covers behavior. It is not meant to be one test for each function or class, because that couples the internal structure (the white box) of your software components far too tightly to your tests. Ian Cooper explained this brilliantly in his talk TDD, Where Did It All Go Wrong.

The refactoring step of TDD is only possible if tests work against a stable facade, behind which there might be a single function today or a cluster of collaborating classes tomorrow (for example, after a refactoring).

Which abstraction layer should you test?

It is usually a bad idea to write so-called technical tests, such as tests that only check getters and setters, or even worse, tests that assert on the internal implementation details of a component.

Instead, tests should focus on behavior that aligns directly with behavioral requirements and user stories. This way, implementation details stay flexible, and tests only break when actual requirements change.

For example, looking at Matt Pocock’s TDD skill, we see a great way to instruct agents to write behavioral tests instead of implementation-coupled tests.


Designing Architecture and Expressive Specs for Agents

To make behavioral testing work in practice, both our software architecture and our test design need to support it:

  • Architectural design for testable layers: Fast behavioral tests require an architecture that exposes clear seams and facades. For example, using the Model-View-ViewModel (MVVM) pattern in frontend or mobile applications lets us test complex presentation and interaction behavior directly against the ViewModel in milliseconds, without spinning up a heavy browser or User Interface (UI) runtime. Clean Architecture also focuses on making architectural layers testable.
  • Behavior-Driven Development (BDD): Structuring scenarios with Given-When-Then keeps tests focused on domain behavior rather than internal mechanics. It creates a shared language between human requirements and agent execution.
  • Helper Domain-Specific Languages (DSLs) and tests as data: When domain models or application states get complex, standard assertions quickly become noisy and hard to read. Building small helper Domain-Specific Languages (DSLs) lets us set up and assert complex domain models in a compact, human-readable way (as we explored in our post on Sociable BDD with Internal DSLs). In his article Tests as data, Matteo Vaccari takes this further: moving test specifications out of verbose test code and into structured data (such as tabular test cases, text scenarios, or bespoke DSL strings) strips away technical boilerplate so only the inputs, actions, and expected state remain.

Going Beyond Example-Based Tests: Property-Based Testing, Fuzzing, and Mutation Testing

Because coding agents generate large volumes of code at high speed, example-based tests alone are sometimes not enough to catch subtle edge cases or weak assertions. Three classic techniques become superpower tools in agentic workflows:

  • Property-Based Testing (PBT): Instead of checking a handful of hardcoded input examples, property-based tests define general invariants (properties) that must always hold true and automatically generate hundreds of varied inputs to try to break them.
  • Fuzzing: Feeding random, malformed, or unexpected inputs into parsers, Application Programming Interfaces (APIs), and domain boundaries helps uncover crashes, security issues, and unhandled edge cases that neither the human nor the agent thought of.
  • Mutation Testing: A green test suite only helps if the tests actually fail when the code is broken. Mutation testing automatically injects small faults (mutants) into the production code to verify that the test suite catches them. In agentic engineering, this is a great safeguard against agents writing superficial tests that pass without truly verifying behavior.

Reviewing “Goldens” Instead of 50k Lines of Production Code

In agentic setups, teams often want to avoid heavy, line-by-line code reviews so they can actually realize the speed gains of coding agents. In my opinion, however, good spec-like tests are still worth reviewing.

When I get a large Pull Request (PR) from my coding agents, I focus my review on the tests written at the behavioral abstraction level: I review the “goldens” (the tests aligned directly with user requirements). If those golden tests are green and the overall test strategy fits, I can sleep well at night without reviewing 50k Lines of Code (LOC) in the generated production diff. This is similar to how I trust the work of junior developers without babysitting their code implementation.

Matteo Vaccari frames this shift well in Tests as data by drawing on Extreme Programming (XP): when Artificial Intelligence (AI) agents write the production code, human developers effectively become the customers of that code. Consequently, black-box customer tests (rather than low-level, implementation-coupled developer tests) become the primary contract between humans and coding agents.

Vaccari also highlights a subtle risk in agentic workflows: when coding agents refactor production code or add features, they frequently refactor existing test code at the same time, making it easy for weakened assertions or altered business rules to slip through review. Expressing golden specifications as tests as data (in tables, text files, or dedicated DSL blocks separated from test runner plumbing) makes the behavioral contract much easier for humans to read, diff, and protect from silent agent edits during refactoring (for example, through read-only file hooks or CI checks).

I see the exact same principle for quality requirements (such as performance, security, or resilience) and the automated tests that verify them. All acceptance criteria, whether functional or qualitative, should be captured in these automated tests. In a business-critical agentic PR, those tests are my contract.


Summary

Agentic engineering scales up code generation, which makes classic testing fundamentals more important, not less. Relying solely on slow E2E tests or brittle, implementation-coupled unit tests creates a bottleneck for both agents and humans. By designing architectures with clear testing layers (such as ViewModels in MVVM), writing expressive BDD scenarios with helper DSLs, strengthening suites with property-based testing, fuzzing, and mutation testing, and focusing human reviews on the “golden” acceptance tests rather than every line of generated production code, we get the full speed of agentic engineering without sacrificing confidence.