Eval-Driven Development in AL: Letting AI Write Code You Can Trust

Note: This blog is a personal notebook. I write it to record what I work on, for my own reference, not to publish it on social media or to promote myself. If a post is still useful to you, I am glad, but that is not why it exists.

This post was published on January 17, 2026. Software versions, product features, links, and tool availability may have changed since then. Always check official documentation for the latest information. Some screenshots show small details. Zoom in on the page to see them clearly.

Most teams that use AI for AL know the pattern: describe the feature, get code that looks correct, review it quickly, and continue. If nobody defined what correct means, the review has no basis.

Eval-Driven Development (EDD) fixes this. You define correctness first, as tests. Then the AI writes the code against that contract.


Problem

The largest weakness in AI-assisted development is an incomplete specification. With an unclear requirement, the AI still writes code that compiles, reads well, and passes a quick review. That is not enough for pricing, validation, posting, or financial logic.


Why this matters

Nobody buys glasses that just look right. The eye test comes first and gives a prescription, and the optician makes the lenses to match. In EDD, the tests are the prescription.

The review improves too: “What must this feature prove?” is far more specific than “Does this code look correct?”


Architecture

EDD is a workflow, not a formal framework:

  1. Write the requirement in plain language.
  2. Discuss the test coverage with the AI.
  3. Let the AI write the tests.
  4. Review and approve the tests.
  5. Let the AI write the code.
  6. Run the tests and feed the failures back.
  7. Check that passing tests show the real business intent.
Step Primary owner
Requirement Developer / consultant
Coverage discussion Developer + AI
Test writing AI
Test review Developer
Implementation AI
Final validation Developer

Demo steps

A simple discount rule shows the method.

Requirement

Feature: Customer discount calculation

Business rules:
- Amount > 1000: apply 10% discount
- Amount <= 1000: no discount
- Discount result must never be negative

Step 1: Discuss the coverage

Before you ask for code, ask what the tests must cover: above the limit, below the limit, the exact boundary at 1000, a zero amount, and a negative input. Unclear intent becomes explicit scope.

Step 2: Let the AI write the tests

The AI turns the agreed coverage into AL test code.

Step 3: Review the tests

This is the main control point. A passing test that checks the wrong condition gives false confidence.

Step 4: Let the AI write the code

The AI now has a clear target.

Step 5: Run and iterate

If the code uses >= instead of >, the boundary test fails immediately.


Risks and limits

  • Bad requirements still give bad results.
  • A missing edge case is still a blind spot.
  • The AI can write an incorrect test.
  • EDD does not replace integration, user acceptance, or regression tests.

The most common mistake is to skip the coverage discussion. The contract is then weak.


Next iteration

  • Connect the tests to CI.
  • Reuse the AL test helpers and data builders.
  • Standardize the prompts for coverage discussions.

Closing note

EDD separates two tasks: deciding what correct means, and writing code that satisfies it. The AI is good at the second. The first is yours.

← Back to AI