Agentic Coding in Practice: A Three-Level Testing Framework for Code Generation and Frontend Design
A practical framework for evaluating AI coding agents beyond whether they can generate syntactically valid code. This article introduces three testing levels—functional correctness, interaction and state completeness, and visual quality—along with structured prompts and an agent workflow for building more reliable, production-ready frontend experiences.
Agentic Coding in Practice: A Three-Level Testing Framework for Code Generation and Frontend Design
In code generation, there is still a significant gap between a model that can write code and one that can deliver a usable frontend application. Code may be syntactically correct while missing edge-case handling. A page may render successfully but fall short in interaction states, responsive behavior, or visual details.
For developers, meaningful evaluation should not rely on a single generated result. It should use a reproducible, layered, and regression-friendly testing methodology.
This article presents a three-level testing framework for agentic coding:
- L1: Functional correctness
- L2: Interaction and state completeness
- L3: Visual quality and user experience
The framework is not tied to any specific product. It can be used to evaluate the practical capabilities of large language models for complex frontend development tasks.
1. Why Layered Testing Matters
Traditional code-generation evaluations often fall into one of two extremes. They either judge whether the code “looks right” without verifying whether it runs, or focus only on the final screenshot while ignoring state management and failure paths.
Frontend tasks are especially challenging because they combine logic, interaction, and visual design. Without layered criteria, evaluation results can be distorted by a few impressive demonstrations.
The core idea behind layered testing is to break “usable” into verifiable acceptance criteria:
- L1 — Functional correctness: Can the code run? Does the core workflow work end to end? Are edge cases handled?
- L2 — Interaction and state completeness: Are loading, empty, error, and disabled states covered? Are interaction responses consistent?
- L3 — Visual quality and experience details: Do hierarchy, spacing, color, motion, responsiveness, and accessibility meet delivery standards?
Each level should have explicit pass conditions, and test results should be recorded. This makes it easier to distinguish demonstration-level code from engineering-ready code.
2. L1: Functional Correctness Testing
L1 focuses on whether the implementation actually works. Instead of providing a vague request, define an actionable task with clear inputs, outputs, constraints, and failure conditions.
Recommended checks include:
- Runtime readiness: Can the generated code start in a clean environment? Are its dependencies clearly specified?
- Complete core workflow: Is the primary path complete, such as loading a list, submitting a form, and displaying the result?
- Edge-case handling: Are empty data sets, long text, duplicate submissions, and network failures handled?
- Maintainability: Are components reasonably structured? Are names clear? Is duplicate logic avoided?
- Testing awareness: Does the model provide test cases or self-check steps?
For example, an acceptance requirement could be written as follows:
Implement a task list component with the following requirements:- Support adding, completing, and deleting tasks;- Display an empty state when there are no tasks;- Disable submission and show a message when the input is empty;- Require confirmation before deletion;- Provide at least three executable self-test cases.
If the model only produces the page structure without explaining state changes or failure handling, the implementation should not pass L1.
3. L2: Interaction and State Completeness Testing
L2 focuses on whether the application is smooth and predictable to use. In frontend development, quality differences often appear outside the primary path—in the details of each state.
The model should be asked to explicitly define the state model rather than scattering state logic across event handlers.
Key areas to check include:
- Loading states: Do asynchronous operations provide a skeleton screen, progress indicator, or disabled feedback?
- Empty and error states: Are no-data conditions, retry flows, and timeouts clearly communicated?
- Interaction consistency: Do buttons, forms, and dialogs provide consistent feedback?
- Responsive layout: Do narrow viewports cause overflow, occlusion, or broken visual hierarchy?
- Accessibility: Are keyboard interactions, focus management, and semantic elements handled appropriately?
You can add a state checklist directly to the prompt:
First, list all component states: initial, loading, success, empty data, error,submitting, and submission failure.Then implement the code and ensure that every state has corresponding UI feedback.Finally, output a state-to-UI mapping table.
This requirement can significantly reduce the common problem of having a usable primary path but incomplete exception handling.
4. L3: Visual Quality and Experience Testing
L3 evaluates whether the interface feels intentionally designed. Visual quality is not purely subjective; it can be broken down into observable dimensions:
- Information hierarchy: Are titles, body text, and supporting information clearly differentiated?
- Spacing system: Is a consistent spacing scale used instead of arbitrary values?
- Color discipline: Are primary, accent, and error colors used for clearly defined purposes?
- Whitespace and density: Are dense information areas readable? Does the empty state feel natural?
- Motion restraint: Does animation support state changes instead of distracting from the task?
- Brand consistency: Are corner radii, shadows, and typography levels consistent?
It is more effective to provide explicit design tokens than to ask the model to “make it look better.” For example:
Design constraints:- Use an 8px spacing system;- Use the primary color only for primary actions and selected states;- Use a consistent 12px card radius;- Define three typography levels for headings, body text, and supporting text;- Keep animation durations between 150 and 250ms;- Support a single-column layout on narrow screens.
Specific constraints are easier for a model to follow and easier for humans to review.
5. Improving Complex Tasks with an Agentic Feedback Loop
The value of agentic coding lies in creating a closed loop of planning, generation, execution, and correction. For complex frontend tasks, the model can be instructed to follow this process:
- Decompose the task: Break it into the data model, component structure, interaction states, and style constraints.
- Retrieve context: Use project documentation, API contracts, and design guidelines to identify additional constraints.
- Generate the implementation: Produce runnable code and explain key decisions.
- Run self-checks: List test steps and simulate invalid or abnormal inputs.
- Self-correct: Fix inconsistencies before producing the final version.
- Perform regression checks: Confirm that changes have not broken existing states or styles.
The workflow can be represented with the following pseudocode:
plan = decompose(requirement)context = load(project_docs, design_tokens, api_contract)code = generate(plan, context)result = run_checks(code)while result.has_error:code = repair(code, result.errors)result = run_checks(code)return code + test_report
When evaluating an agent, pay attention not only to the final code but also to whether it can explain why a repair was necessary.
6. Advanced Prompting Techniques
A high-quality prompt should include five types of information:
- Role
- Objective
- Constraints
- Acceptance criteria
- Output format
A recommended template is:
You are a senior frontend engineer. Implement [task objective].Constraints:1. Do not introduce additional dependencies;2. Use semantic HTML and native CSS;3. Include loading, empty, error, and success states;4. Automatically switch to a single-column layout on narrow screens;5. Output the complete code and a self-test checklist.Acceptance criteria:- The core workflow must run;- Failure paths must provide feedback;- Style variables must be centrally managed.
You can also ask the model to output a plan before writing code. In a second round, ask it to list only risks and missing cases. This can reveal edge conditions that were overlooked in the first pass.
For visual design tasks, provide concrete design tokens rather than abstract adjectives such as “modern” or “beautiful.”
7. Implementation Recommendations
For production use, convert the three-level framework into a regression checklist:
- Use runnable scripts and core test cases for L1.
- Use a state-to-UI mapping table for L2.
- Use screenshot reviews and design-system comparisons for L3.
For frequently generated tasks, retain prompt versions, generated outputs, and repair records. This makes later analysis and improvement easier.
Resource usage should also be matched to task complexity. Choose context length and iteration count deliberately instead of retrying without limits.
Overall, code-generation evaluation should move from isolated “wow” results to layered, verifiable acceptance. By combining L1 functional testing, L2 interaction and state testing, and L3 visual quality testing with an agentic feedback loop and structured prompts, developers can more reliably understand both the capabilities and the boundaries of AI coding models in real-world projects.
