Test automation for Dynamics 365
By Emil Björk · Microsoft business apps consultant, Gothenburg
How to automate testing for Dynamics 365 — AL test framework, EasyRepro for CRM, Playwright for web UIs, and the strategy that actually pays back.
On this page (12)
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
- Entra ID authentication errors for Dynamics 365The AADSTS sign-in errors Dynamics 365 users and integrations hit most — decoded, with cause, fix, and prevention.
- Dynamics 365 licensing explainedThe whole Dynamics 365 licensing model in one place — base and attach licences, per-user tiers, Team Members, device licences.
- Dynamics 365 vs SAPThe two enterprise ERP conversations that actually happen — S/4HANA vs Finance & Operations, and Business One vs Business Central — where each side wins.
- Dynamics 365 2026 wave 2 release highlightsThe October 2026 update cycle is the first without a formal release wave plan — what Microsoft changed, what still ships.
- Dynamics 365 and the Power PlatformHow the Power Platform extends, automates, analyses, and surfaces AI on top of every Dynamics 365 app.
Browse every guide in Foundations.
Was this helpful?
Signals which guides land and which need work. No account, no comment box — corrections go through the contact page.
Spot something wrong or want a topic covered? Send a correction or a topic request — both are welcome.