Adyen’s Approach to Augmented Unit Test Generation with LLMs

At Adyen, code quality is non-negotiable. As their systems grew in complexity, ensuring consistency and reliability in unit testing became both more important and more resource-intensive. This sparked a question: can Large Language Models (LLMs) do more than generate boilerplate code? Could they augment the creation of high-quality unit tests?

The answer led them to a unique approach that goes beyond traditional text-driven AI.

👉 The Problem with Conventional LLM Use in Code

LLMs like GitHub Copilot are great at writing small functions or snippets. But in real-world engineering, code lives inside large, interconnected frameworks. Writing meaningful unit tests requires more than recognizing patterns; it demands understanding dependencies, state management, and how methods interact within the wider codebase.

Traditional Retrieval-Augmented Generation (RAG) helps provide context, while fine-tuning sharpens accuracy. Yet both approaches hit limits in code: embeddings miss subtle semantics, and fine-tuning is resource-heavy for fast-moving repositories. Code isn’t just text—it’s architecture.

✅ Adyen’s Breakthrough: ASTs and Knowledge Graphs

To bridge this gap, Adyen moved beyond plain embeddings to structural and semantic representations of code.

🔹 Abstract Syntax Trees (ASTs)

ASTs break source code into a hierarchical tree. Each node represents constructs like variables, methods, or conditions. This allows them to see the scope of variables, sequence of function calls, and control flow—things that raw text can’t capture.

ASTs give the LLM a map of the code’s skeleton, ensuring it doesn’t just guess but understands logic and architecture.

🔹 Knowledge Graphs (KGs)

They extend ASTs by constructing Knowledge Graphs. Here, entities (functions, classes, objects) are nodes, and relationships (inheritance, dependencies, interactions) form edges. Unlike embeddings, which rely on semantic similarity, KGs reveal actual connections across the codebase.

This lets the system answer questions like: Which methods depend on this variable? How does this class interact with others?—insights critical for generating unit tests that reflect real functionality.

👉 The Workflow

🔹 Parse the codebase into ASTs → expose syntax and structure.

🔹 Build Knowledge Graphs → enrich ASTs with semantic links.

🔹 Store graphs in a database → enabling precise, context-aware queries.

🔹 Feed relevant context to the LLM → not just snippets, but full structural understanding.

🔹 Generate unit tests → consistent, logically sound, and aligned with Adyen’s standards.

👉 Why It Works

This hybrid approach solves the two biggest hurdles:

🔹 Context sensitivity → ASTs and KGs together capture dependencies, 🔹 hierarchies, and hidden flows.

🔹 Consistency → the system reduces variability in test quality by giving LLMs the right context every time.

Source: Adyen


#fintech #payments #ai