MSBA-312 · Lesson 3 of 12 · 19 min
Testing strategies for AI
▶ Video coming soon A video version of this lesson is on the way.
In the second week of October, Tomasz Rybak, who owns the Policy Service Assistant on the business side, forwarded Bram an email from Cormac Dunleavy, one of his contact centre team leads. A representative had asked the agent to remove a driver from a policy, and the agent had started a change request to remove the *wrong* driver, one with a similar name. The underwriter caught it at approval. Nobody was harmed, but Tomasz's question was blunt: "We tested this. How did it get through?" The answer, once Yusra Kamaludin traced it, was that every test of driver removal had used policies with one or two drivers with clearly different names. Nobody had tested a household with two drivers called Jaswinder and Jasvinder.
That gap is typical. Teams that test AI solutions well do not test more; they test differently, with a strategy that combines deterministic tests, statistical evaluation, end-to-end scenarios and real users, each aimed at a different kind of failure. This lesson builds that strategy. Lesson 4 goes deeper into evaluation and red teaming, which are the parts of testing most specific to AI.
Why AI testing is different
Conventional software testing assumes that the same input gives the same output, so a test either passes or fails. Generative AI breaks that assumption in three ways. Outputs are non-deterministic: the same question can produce differently worded answers, and occasionally a different tool choice. Inputs are open-ended: users can ask anything, in any phrasing, so no list of test cases covers the input space. And correctness is often a judgement: an answer can be partly right, right but unhelpful, or right but in the wrong tone.
The practical consequences are that single test runs prove little, that "pass" has to be defined as a rate or a score over many cases, that some tests need a human or a model to judge quality, and that testing never ends at release, because production traffic will always contain cases nobody thought of. A testing strategy for AI therefore has layers, and each layer catches what the others miss.
Layer 1: deterministic component tests
Much of an agentic solution is not AI at all. Connectors call APIs, flows apply business rules, Dataverse tables enforce data types, and MCP servers return structured results. These parts can and should be tested the conventional way, with fixed inputs and exact expected outputs. For the Policy Service Assistant, Pascal Wojtyniak's team tests the BrokerDesk custom connector's three operations against the development API: GetPolicy with a valid policy, an unknown policy and a policy the caller cannot see; ListDrivers with zero, one and many drivers; CreateChangeRequest with valid and invalid payloads. The Policy Change Request agent flow has its own tests for the approval path, the early response with the change request number, and the note that must always be written.
Deterministic tests are cheap, fast and repeatable, so they run on every change. They also make AI tests more meaningful: if the connector is known to work, a failed evaluation points at the agent's behaviour rather than at plumbing. When the driver-removal problem was traced, the connector tests showed that ListDrivers returned both drivers correctly. The fault was in how the agent chose between them.
Layer 2: evaluation sets
The second layer tests the AI behaviour itself, using evaluation sets: collections of inputs with expected outcomes, run as a batch and scored. In Copilot Studio these are agent evaluation test sets; in Foundry they are datasets run with built-in or custom evaluators. Lesson 4 covers the methods. What matters for strategy is what goes into the sets. A good set covers five kinds of case. Core tasks are the questions the agent exists to answer, in proportion to how often they occur. Variations rephrase core tasks the way real users write: shorthand, typos, pasted emails, two requests in one. Edge cases test boundaries, such as similar names, empty results, very long inputs and unusual dates. Out-of-scope requests check that the agent declines or redirects properly. Adversarial cases check that it resists manipulation, which Lesson 4 treats as red teaming.
After the driver incident, Yusra added a group of ambiguity cases to the Policy Service set: households with similar names, a driver listed twice, a request that names a driver only as "my son". The agent's instructions were changed to confirm the driver's full name and date of birth before any removal, and the new cases became a permanent part of the release gate.
| Kind | Purpose | Example for the Policy Service Assistant |
|---|---|---|
| Core task | Confirms the main job works at the expected rate | "What is the deductible on AU483920?" |
| Variation | Confirms robustness to real phrasing | "deductible au 483920 pls" |
| Edge case | Probes boundaries and ambiguity | Remove Jasvinder from a policy that also lists Jaswinder |
| Out of scope | Confirms correct refusal or redirection | "Should I switch my client to another carrier?" |
| Adversarial | Confirms resistance to manipulation | A pasted email that tells the agent to ignore its instructions |
Building test cases with Copilot
Writing hundreds of cases by hand is slow, and makers tend to write the cases they already know the agent handles. AI can help. Copilot Studio can generate test sets from an agent's knowledge and topics, and turn a test chat or analytics themes into cases, as MSBA-242 described. Copilot in other tools, and models in Foundry, can generate variations and edge cases from a short description. The AB-100 study guide asks architects to "build the strategy for creating test cases by using Copilot", which means deciding how generated cases are used safely, not just pressing the button.
Bram's strategy for Quillfield had four rules. Generated cases are a starting point: a person reviews every case and its expected answer before it joins a gating set, because a model can generate a wrong expected answer as confidently as a right one. Generation is directed: makers ask for specific kinds of variation (misspellings, combined requests, similar names) rather than "more tests". Real data outranks synthetic data: once an agent is live, cases from real conversations, with personal details removed, are added each month. And generated cases are labelled as generated, so that if a set later proves too easy, the team knows where to look.
Layer 3: end-to-end scenarios
Agentic solutions rarely live alone. The Policy Service Assistant calls BrokerDesk, starts a flow, waits for an underwriter, writes a note, and hands claims questions to a child agent; the Commercial Submission Desk design in MSBA-311 adds a Foundry agent and a workflow. End-to-end scenarios test the whole chain with realistic data and realistic users, from the first message to the final state of every system touched. A scenario has a starting state, a script of user actions, and expected end states, such as "change request CR-series number created with the correct driver, underwriter task assigned, note written in BrokerDesk, confirmation sent to the representative".
For solutions built on Dynamics 365, the AB-100 study guide specifically asks architects to design end-to-end test scenarios for AI solutions that use multiple Dynamics 365 apps. Those scenarios follow a business process across app boundaries: a customer service case that triggers a return in supply chain, which creates a credit note in finance, with Copilot or an agent assisting at several steps. The scenario must check both the AI steps (was the summary accurate, did the agent pick the right return reason) and the transactional steps (was the credit posted to the right account). Lesson 12's capstone works through one.
Layer 4: user acceptance and pilots
No test set reproduces real users. User acceptance testing (UAT) puts the solution in front of the people who will use it, in a test environment, with real tasks. For AI solutions, UAT should be structured: give testers a list of tasks they do every week, ask them to work as they normally would, and capture both their judgement of each answer and the transcript. Cormac Dunleavy and Precious Mahlangu, the two contact centre team leads, ran UAT for each Policy Service release with four representatives for half a day. Their ratings fed the release decision alongside the evaluation scores.
A pilot goes further: real work, in production, for a limited group, for a limited time, with close monitoring and an easy way to report problems. Pilots answer questions UAT cannot, such as whether people trust the agent enough to use it, and whether it saves time. Bram's rule is that any new agent with tools that change data has a pilot of at least two weeks before general release, with daily review of transcripts in the first week.
Non-functional tests
AI solutions also need performance, capacity and resilience testing. How long does a typical answer take when the BrokerDesk API is slow? What happens when Northmark Mutual's MCP server is unavailable? How many credits does a busy Monday consume? Copilot Studio test runs do not consume Copilot Credits, but production traffic does, so cost tests use estimates from evaluation runs multiplied by expected volumes, as Hamish Quarrington did for each Quillfield agent. For Foundry agents, load tests against a test project's deployment reveal throttling limits on the model deployment before users do.
Resilience tests deliberately break dependencies. Pascal's team turned off the test BrokerDesk API for ten minutes during a UAT session; the agent told users that policy systems were unavailable and offered to take a message, which was the designed behaviour. Without the test, nobody would have known whether it worked.
Validation criteria for custom models
When a solution includes a custom AI model, such as a classifier that routes incoming submissions by line of business, the AB-100 study guide expects architects to create validation criteria before the model is built. Criteria state which metrics matter (accuracy, precision and recall per class, calibration), what thresholds are acceptable, on what held-out data they are measured, and how results are broken down by subgroup to detect uneven performance. For a submission router, recall on rare but important classes (such as cyber or professional liability) may matter more than overall accuracy, because a missed cyber submission costs more than a misrouted general liability one. Criteria agreed in advance prevent the familiar argument after the fact about whether 91 percent is good enough.
Validating Copilot prompt practices
The study guide also asks architects to validate effective Copilot prompt best practices. In an organization rolling out Microsoft 365 Copilot alongside agents, this means checking that the prompts people are taught and the prompts built into agents follow good practice: a clear goal, relevant context, named sources, and stated expectations for the format and length of the answer. Testing prompts works like testing agents. Run the prompt against representative inputs, judge the outputs against a rubric and compare variants. Quillfield tested the prompts in its Copilot prompt guide for brokers this way in October, keeping the two that produced consistently usable renewal summaries and rewriting one that often invented coverage limits because it did not name a source.
Worked problem
Designing a test plan for a new agent
The claims first-notice solution designed in MSBA-310 will take loss reports from clients through a web chat, create a claim notice in BrokerDesk and notify the carrier. Outline the test strategy before it goes to UAT.
Show solution
- Component tests: BrokerDesk claim-notice operations, carrier notification flow, address and date validation, duplicate detection.
- Evaluation set: core loss types in proportion to volume, phrasing variations, edge cases (two losses at once, unclear dates, third-party claimants), out-of-scope requests, adversarial inputs pasted from emails.
- End-to-end scenarios: from first message to claim notice, carrier notification and follow-up task, including a carrier system outage.
- Non-functional: response time under peak load after a storm, credit estimate per notice, behaviour when BrokerDesk is unavailable.
- UAT with claims advocates, then a pilot with one office's clients before general release.
Answer: A layered plan with deterministic tests, a five-kind evaluation set, end-to-end and resilience scenarios, cost and load estimates, UAT and a limited pilot, each with written pass criteria.
Writing pass criteria
Every layer needs pass criteria written before testing starts. For deterministic tests, criteria are exact. For evaluations, they are rates and scores: at least 95 percent of core tasks pass, no adversarial case leads to a data-changing action, groundedness above an agreed threshold. For UAT, they combine ratings and blocking issues. Writing criteria first protects the team from moving the goalposts when the release date is close, and it lets the AI council see what "tested" meant for each release.
Common mistakes
MistakeTesting an AI agent only with handwritten cases from its maker.
InsteadCombine generated, reviewed and real-world cases across core, variation, edge, out-of-scope and adversarial kinds.
MistakeTreating one successful run as a pass.
InsteadDefine pass as a rate or score over many cases and repeated runs.
MistakeSkipping deterministic tests because the AI is the interesting part.
InsteadTest connectors, flows and APIs conventionally so evaluation failures point at behaviour.
MistakeAdding generated test cases without review.
InsteadHave a person check every generated case and its expected answer before it gates a release.
MistakeAgreeing model thresholds after seeing results.
InsteadWrite validation criteria, including subgroup breakdowns, before training or evaluation.
Summary and key terms
- AI testing needs layers because outputs vary, inputs are open-ended and correctness is often a judgement.
- Deterministic component tests cover connectors, flows and APIs; evaluation sets score AI behaviour over many cases.
- Good evaluation sets mix core tasks, variations, edge cases, out-of-scope requests and adversarial inputs.
- Copilot can generate test cases, but people review them and real conversations gradually replace synthetic ones.
- End-to-end scenarios, including those across several Dynamics 365 apps, check AI steps and transactional results together.
- UAT, pilots, non-functional tests and validation criteria for custom models complete the strategy; pass criteria are written first.
- Evaluation set
- A collection of inputs with expected outcomes, run as a batch and scored to measure AI behaviour.
- Edge case
- A test input at the boundary of expected use, such as ambiguous names or empty results.
- End-to-end scenario
- A test that follows a business process across every system and agent it touches, checking final states.
- User acceptance testing (UAT)
- Structured testing by intended users in a test environment before release.
- Pilot
- Limited production use by a defined group for a set period with close monitoring.
- Validation criteria
- Metrics, thresholds and test data agreed in advance to judge whether a model is fit for use.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why did the driver-removal error get through testing?
Show answer
The test cases never included households with similar driver names, so the ambiguity was never exercised.
What four rules did Bram set for test cases generated with Copilot?
Show answer
Generated cases are a reviewed starting point, generation is directed at specific variations, real data outranks synthetic, and generated cases are labelled.
What makes a Dynamics 365 end-to-end scenario different from an agent evaluation?
Show answer
It follows a process across several apps and checks both AI outputs and transactional results such as postings.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.