Test automation for Dynamics 365
How to automate testing for Dynamics 365 — AL test framework, EasyRepro for CRM, Playwright for web UIs, and the strategy that actually pays back.
Test automation in Dynamics 365 is genuinely hard. The platform spans AL, X++, JavaScript, Power Fx, Dataverse plug-ins, Power Automate flows, and web UIs — each with different tooling. Done thoughtfully, automation catches regressions that release waves silently introduce; done badly, it's a maintenance burden that gets abandoned. The strategy matters more than any specific tool.
What to automate. Not everything. Prioritise:
- Posting paths — the transactional code that puts data into the GL or sub-ledgers. Most consequential if it regresses.
- Custom AL or X++ code — your own extensions. Microsoft tests their own; you test yours.
- Critical integrations — flows that move data across systems. Silent failures here are expensive.
- High-volume / high-frequency processes — anything users hit hundreds of times a day, where a UI change costs operations.
What not to automate. UI tests that depend on Microsoft's standard pages. Microsoft changes them release-by-release and your tests become a maintenance treadmill chasing those changes. Test your extensions; trust Microsoft to test theirs.
Layer 1: AL test framework (Business Central). Built-in. Run by the bccontainerhelper PowerShell module in containers. Each AL test codeunit holds test methods with [Test] attributes. Tests run in rolled-back transactions so they're re-runnable. Microsoft ships Test Libraries with helper functions for creating customers, items, sales documents, etc. Use them.
Layer 2: Dataverse plug-in unit tests. C# plug-ins have plain .NET unit tests using FakeXrmEasy or XrmUnitTest — frameworks that mock the Dataverse SDK so plug-ins can be tested without a real Dataverse environment. Fast, run in CI, catch logic bugs.
Layer 3: Power Automate flow tests. Power Automate has built-in flow checker and a Power Automate Test Framework for unit-testing flow logic with mocked actions. Less mature than other layers, improving.
Layer 4: Power Apps tests. Canvas apps support Power Apps Test Studio for recorded test flows. Model-driven apps test through web UI automation.
Layer 5: UI automation. Two leading tools:
-
EasyRepro — Microsoft's open-source library on top of Selenium, targeting Dynamics 365 model-driven apps. C# tests script user interactions: open opportunity, set field, click save, verify result. Robust against Microsoft's web UI changes (Microsoft maintains it alongside the product).
-
Playwright — Microsoft's modern web testing framework, language-agnostic (TypeScript, Python, C#, Java). Increasingly preferred for new projects given its broader cross-application capability — test a Dynamics 365 form, a Power Pages portal, and a Power Apps canvas app in one suite.
For Business Central web client, Playwright or Selenium drive the UI; pattern is similar.
Layer 6: Integration tests. End-to-end scenarios that span multiple systems. Often built in Power Automate flows that perform the test scenario, capture results, post to Dataverse for tracking. Or in dedicated test orchestrators like Azure Test Plans or TestFlight.
CI/CD integration. Tests at every layer run in CI:
- Unit tests on PR build.
- Integration tests on merge to main.
- UI smoke tests in UAT after deploy.
- Full regression suite weekly or before production deploys.
Test data. A persistent challenge — tests need data that survives release-wave updates and resets. Patterns:
- Self-creating tests — each test creates the data it needs (customers, products, orders) and rolls back.
- Reference data sets — a small set of stable test records preserved through resets.
- Synthetic data — generated programmatically for volume / performance tests.
Maintenance. Automated tests rot. Schedule quarterly review — which tests still pass, which fail false-positively, which haven't run in months. Retire what's dead; refactor what's flaky.
Operational reality. Start small. 20 well-maintained tests on critical paths beat 200 flaky tests nobody trusts. Build the culture of "every bug deserves a test" so the suite grows from real lived experience, not aspirational planning.
Related guides
- Accessibility in Dynamics 365 appsHow Dynamics 365 supports accessibility — keyboard navigation, screen readers, colour contrast, ARIA, and the requirements for compliance with WCAG, Section 508, and EN 301 549.
- Data protection and compliance for Dynamics 365How to address data protection and compliance requirements for Dynamics 365 — GDPR, HIPAA, SOX, industry regulations, and the operational practices.
- Drop shipments and special orders in Business CentralHow Business Central links sales orders to purchase orders for drop-ship and special-order fulfilment — the requisition worksheet, the linkage, and the gotchas.
- Dynamics 365 and Azure OpenAIHow Azure OpenAI powers AI features in Dynamics 365 — under-the-hood model usage, custom AI scenarios, and the patterns for integrating LLMs with Dynamics.
- Dynamics 365 and Conditional AccessHow Conditional Access protects Dynamics 365 — policy patterns, MFA, device compliance, location-based controls, and the Zero Trust patterns.