Skip to main content
XenonStack

Software Testing

XenonStack Blog Domain-Driven Testing for Test Automation Architecture

and | Published | Updated

Domain-Driven Testing for Test Automation Architecture
13:57

Key takeaway

  • Domain-driven testing explained: a domain-specific language for test automation, layered architecture, a worked example, AI test agents and adoption.

Domain-driven testing is a test automation design pattern in which testers write automated tests in a small domain-specific language, such as New Customer or Place Order, while engineers implement those commands underneath. Tests then describe what the business does, not which buttons are clicked, so they survive interface changes and can be written before the software under test is finished.

It is an architecture decision for your test estate rather than a development practice. If you are deciding how code is written test-first, read our guide to test-driven development (TDD); this post covers how to structure automated tests so that business-readable test cases, reusable domain commands and tool-specific code live in separate layers.

What is domain-driven testing in test automation?

The Test Automation Patterns wiki, created by Seretta Gamba and Dorothy Graham and hosted by EuroSTAR, lists DOMAIN-DRIVEN TESTING as a design pattern with the summary: "Develop a domain-specific language for testers to use when writing their automated test cases." It says the pattern fits when testers should be able to write and run automated tests, including before the software under test (SUT) is complete, and that it is not appropriate for very small-scale or one-off automation efforts (Test Automation Patterns).

In practice, each action in the business domain becomes a command with parameters. To add a customer, a tester writes something like New Customer FirstName LastName HouseNo Street PostCode City and supplies the data. Once the vocabulary is agreed, test cases can be written against it while the application is still being built, and engineers implement each command when the interface is ready.

The Selenium project recommends the same idea under the name domain-specific language: tests should use language such as "create a new account" rather than "click on the third column", and keeping implementation details out of test cases leaves them "well-insulated against changes" to the application under test (Selenium documentation).

How does domain-driven testing differ from TDD, BDD and keyword-driven testing?

These terms are often mixed up. They answer different questions, and an enterprise test estate usually combines several of them.

Approach What it decides Who usually writes the tests When it fits
Domain-driven testing How automated tests are expressed and layered: a business vocabulary over reusable technical code Testers and analysts, with engineers building the commands Large, long-lived regression suites; mixed-skill teams; tests designed before the SUT is stable
Keyword-driven testing A technique for building that vocabulary from reusable keywords Testers composing keywords; engineers writing low-level libraries Tools such as Robot Framework, which describes itself as a keyword-driven automation framework
Behaviour-driven development (BDD) How teams agree on behaviour, written as Given/When/Then examples Product, test and development together When shared examples drive the requirement conversation
Test-driven development (TDD) The order in which developers write tests and code (red, green, refactor) Developers Unit and component level design; see our TDD guide

A useful rule: BDD and TDD are about when and why tests are written; domain-driven testing is about the shape of the automation code so those tests stay readable and cheap to maintain.

How does a layered test architecture make domain-driven testing work?

The pattern depends on abstraction levels. The wiki notes that to implement a domain-specific language, "scripts or libraries must be written for all the desired domain-commands." Most teams arrive at four layers:

Two-column diagram: business rule changes map to test cases, workflow changes to domain commands, screen or API changes to interface adapters, and tool changes to the tool and driver layer.
Layer What lives there Changes when
Test cases Business scenarios written only in domain commands and test data The business rule changes
Domain commands Reusable actions such as New Customer or Approve Invoice, built from lower-level steps A business workflow changes
Interface adapters Page objects, API clients and data builders that know screens, endpoints and selectors The user interface or API changes
Tool and driver Selenium, Playwright, Robot Framework libraries, HTTP clients You upgrade or replace the tool

Martin Fowler describes the interface-adapter layer as the page object: it "wraps an HTML page, or fragment, with an application-specific API" and "should not make assertions" itself. He adds that if you use a testing DSL, "it's best to layer the testing DSL over the page objects" (martinfowler.com). The Robot Framework user guide (version 7.5.1) supports the same split, with the "ability to create reusable higher-level keywords from the existing keywords" on top of test libraries that hold "the lowest-level keywords" (Robot Framework User Guide). Cucumber does the equivalent by matching each Gherkin step to "a code block, called a step definition" (Cucumber Gherkin reference).

What does a domain-driven test look like?

A Robot Framework example. The test case uses only domain commands; the keyword section hides the screen-level steps, which in turn call a page or API library.

*** Test Cases ***
New customer can place a first order
    New Customer    Ada    Lovelace    12    High Street    AB1 2CD    London
    Place Order     customer=Ada Lovelace    sku=BOOK-001    quantity=1
    Order Status Should Be    Confirmed

*** Keywords ***
New Customer
    [Arguments]    ${first}    ${last}    ${house}    ${street}    ${postcode}    ${city}
    Open Customer Form
    Fill Customer Details    ${first}    ${last}    ${house}    ${street}    ${postcode}    ${city}
    Save Customer

If the customer screen is redesigned, only Fill Customer Details and the page library underneath change. The test case, and every other test that creates a customer, stays the same. Selenium's documentation makes the same point about its login example: if the fields change, "you would only ever have to change this method - not your tests."

Which test automation problems does domain-driven testing solve?

The Test Automation Patterns wiki lists five issues that this pattern addresses. The table explains each one and how a domain language helps.

Issue What goes wrong How a domain language helps
Late test case design Automated tests are written only after the SUT is implemented Tests are written against agreed commands while the interface is still being built
Manual mimicry Automation copies manual click-by-click scripts Tests describe business actions, so steps can be implemented through faster routes such as APIs
Non-technical testers Domain experts cannot write automation in the tool's scripting language They compose tests from commands; engineers own the code underneath
Obscure tests Tests are long and hard to review Each test reads as a short list of business actions and checks
Too early automation Automation of an unstable interface produces noise The interface-specific layer is filled in when the interface settles, without rewriting tests

How should testware be organised for domain-driven testing?

Scripts, keyword libraries, test data, expected results, actual results, logs and utilities all need a known home. Design that structure around how you want to use automation instead of adopting a tool's default layout, which can tie you to that tool. Copying files into the place a tool expects is easy to automate.

Keep test materials separate from test results. Materials (inputs, expected results, set-up data, environment settings and test descriptions) exist before a run, should have one master copy under version control, and are often shared by many tests. Results (actual outputs, logs, difference files) are produced on every run and build up quickly in a CI/CD pipeline, so decide what to keep: a log proving the test ran is often enough when it passed. In our own delivery work we pair this with synthetic test data generation and contract tests enforced in the pipeline, so domain commands can run without production data. For data-heavy estates, our big data testing services apply the same separation to pipelines and datasets.

How do AI test agents change domain-driven testing in 2026?

AI agents now write and repair test code, which makes a stable domain vocabulary more valuable, not less. Playwright ships three Test Agents: a planner that "explores the app and produces a Markdown test plan", a generator that "transforms the Markdown plan into the Playwright Test files", and a healer that "executes the test suite and automatically repairs failing tests". Its documentation lists VS Code, Claude Code, Codex and OpenCode as supported clients, and warns that generated tests may contain initial errors and that the healer may skip a test if it believes the functionality is broken (Playwright Test Agents).

That last point is the governance issue. A healer that changes selectors in the interface-adapter layer is doing useful maintenance; an agent that edits, skips or weakens a business-level test is changing what the organisation has agreed to check. A domain-driven architecture gives you a clean line: agents may propose changes to adapters and generated plans, while changes to test cases and domain commands go through human review. Teams orchestrating several such agents across delivery workflows can use ElixirClaw, an agentic OS platform to build, orchestrate and govern AI agents and automation workflows while keeping humans in control.

If the application itself includes AI features, deterministic domain commands are not enough on their own, because the same input can produce different outputs. Domain-level checks then need evaluation against expected behaviour; AgentQA provides automated quality assurance for AI, built to catch hallucinations, errors and data quality issues before users do.

What governance, security and cost questions should leaders ask?

Area Question What good looks like
Ownership Who owns the domain vocabulary? A named owner per domain; new commands reviewed like an API change
Change control Who may change test cases, and can an AI agent do it? Agents limited to adapters and drafts; test-case edits need human approval
Test data Do domain commands use production data? Synthetic or masked data; secrets kept out of test materials
Cost Is the up-front investment justified? The wiki warns it "does take time and effort" to build the infrastructure; count reuse across suites before starting
Portability Are domain commands tied to one tool's script language? Domain layer kept thin over adapters so a tool change does not mean starting again

How should an enterprise adopt domain-driven testing?

  1. Pick one business flow with frequent regressions, such as customer onboarding or order to cash.
  2. Agree the vocabulary with testers, analysts and engineers: a small set of commands with clear parameters.
  3. Build the layers: domain commands over page objects or API clients over the tool, with assertions kept in tests.
  4. Set up the testware structure: version-controlled materials, separate results storage, synthetic data.
  5. Run it in CI/CD alongside shift-left testing practices, and track maintenance effort per interface change.
  6. Add AI agents with limits: let them plan and heal adapters; route test-case changes to review.
  7. Extend to non-functional suites, for example automated performance testing that reuses the same domain commands to drive load.

When is domain-driven testing not the right fit?

Skip it for very small or one-off automation, where building a vocabulary costs more than it saves. Be cautious when no engineer is available to maintain the command libraries, because testers then depend entirely on someone else to add or fix commands. Watch for vocabularies that grow without review: hundreds of near-duplicate commands bring back the maintenance cost the pattern was meant to remove. For unit-level design decisions, developer practices such as TDD are a better tool.

What has changed since this guide was first written?

  • The Test Automation Patterns material now lives on a wiki created by Seretta Gamba and Dorothy Graham, moderated by Bryan Bakker and hosted by EuroSTAR.
  • Selenium documents domain-specific languages as an encouraged test practice, with readable, writable, extensible and maintainable as the stated benefits.
  • Robot Framework has reached version 7.5.1 of its user guide, still built around keywords and reusable higher-level keywords.
  • AI test agents, such as Playwright's planner, generator and healer, can now draft and repair tests, which makes the boundary between business tests and technical adapters a governance control.

To map one testing decision your agents should make, and the context and policy it depends on, book a Context Workshop. See what happens in the workshop.

Frequently asked questions about domain-driven testing

What is domain-driven testing?

It is a test automation design pattern in which testers write automated tests in a simple domain-specific language, and engineers implement each domain command in scripts or libraries underneath.

Is domain-driven testing the same as keyword-driven testing?

Not exactly. Keyword-driven testing is a common way to build the domain language, for example with Robot Framework user keywords. Domain-driven testing is the wider design choice to express tests in business terms over layered technical code.

How is domain-driven testing different from TDD?

TDD decides the order in which developers write tests and code. Domain-driven testing decides how automated tests are expressed and layered. A team can use both.

When should you not use domain-driven testing?

It is not appropriate for very small-scale or one-off automation efforts, because building a good domain-driven infrastructure takes time and effort.

Can AI agents write domain-driven tests?

AI agents such as Playwright's planner, generator and healer can draft and repair tests, but generated tests may contain errors and the healer may skip tests. Keep changes to business-level test cases under human review.

Follow XenonStack on LinkedIn: XenonStack on LinkedIn for new guides on agentic AI, data and platform engineering.

Table of Contents

navdeep-singh-gill

Navdeep Singh Gill

Global CEO and Founder of XenonStack

LinkedIn profile

Navdeep Singh Gill is serving as Chief Executive Officer and Product Architect at XenonStack. He holds expertise in building SaaS Platform for Decentralised Big Data management and Governance, AI Marketplace for Operationalising and Scaling. His incredible experience in AI Technologies and Big Data Engineering thrills him to write about different use cases and its approach to solutions.

Get the latest articles in your inbox

Subscribe Now

Related Articles

Interested in solving your challenges with the XenonStack team?
Get Started

Tell us about you and your priorities so we can prepare the right conversation. It takes about 2 minutes.

Please Select your Industry
Banking
Fintech
Payment Providers
Wealth Management
Discrete Manufacturing
Semiconductor
Machinery Manufacturing / Automation
Appliances / Electrical / Electronics
Elevator Manufacturing
Defense & Space Manufacturing
Computers & Electronics / Industrial Machinery
Motor Vehicle Manufacturing
Food and Beverages
Distillery & Wines
Beverages
Shipping
Logistics
Mobility (EV / Public Transport)
Energy & Utilities
Hospitality
Digital Gaming Platforms
SportsTech with AI
Public Safety - Explosives
Public Safety - Firefighting
Public Safety - Surveillance
Public Safety - Others
Media Platforms
City Operations
Airlines & Aviation
Defense Warfare & Drones
Robotics Engineering
Drones Manufacturing
AI Labs for Colleges
AI MSP / Quantum / AGI Institutes
Retail Apparel and Fashion

Continue