Testing
Testing for Business Central extensions: writing automated tests in AL with test codeunits, test methods, test pages, handler methods and test runners. It also covers the Performance Toolkit and Marketplace testing expectations. It answers how to build, run and structure tests.
- 8Learn pages
- 9videos
Path: Development > Extension lifecycle > Testing · tier official · system development · narrative unreviewed (model text not yet checked)
Overview
This section explains how to test Business Central extensions. It starts with an overview of application testing (test codeunits, test methods, test runner codeunits, test pages, UI handlers and the ASSERTERROR keyword), then goes into each building block in its own page.
Test codeunits and test methods are the core. Handler methods intercept UI interactions such as messages, confirmations, pages and reports so tests run without a user. Test pages simulate user actions on pages. Test runner codeunits run test codeunits unattended, with pre- and postprocessing and result logging. A worked example for purchase invoice discounts shows these pieces together with test libraries and GIVEN-WHEN-THEN notation.
Two pages cover wider concerns. The App Testing FAQ describes what to test before Marketplace submission (functional, version and region compatibility, upgrades). The Performance Toolkit extension helps ISVs and VARs simulate workloads and check performance regressions. Start with the overview, then the test codeunits page, and use the example as a template.
Key points
- Test codeunits and test methods in AL use attributes such as TransactionModel and TestDataSource, and properties such as TestIsolation and TestHandlers. The page mentions runtime 16 and runtime 18.
- Handler methods (MessageHandler, ConfirmHandler, StrMenuHandler, PageHandler, ModalPageHandler, ReportHandler) replace user interaction in automated tests.
- Test pages simulate users: read or change fields, reach subpages, filter data, invoke actions and navigate records.
- Test runner codeunits use the TestRunner subtype with OnRun, OnBeforeTestRun and OnAfterTestRun triggers to run tests unattended and log results.
- The purchase invoice discount example uses Library - Random, Library - Purchase, the Assert codeunit and GIVEN-WHEN-THEN structure.
- The App Testing FAQ covers pre-Marketplace testing: functional tests, code coverage guidance, version and region compatibility, upgrade tests and Docker container testing.
- The Performance Toolkit supports test suite configuration, scenario definition, concurrent session simulation, baseline comparison, telemetry integration and Power BI reporting.
Learn pages
- Application Testing Example to Test Purchase Invoice Discounts: Example to demonstrate the application testing scenario.
- In the observatory: Codeunit 70 “Purch.-Calc.Discount”
- Business Central App Testing FAQ: Learn how to test Business Central Marketplace apps across releases and countries/regions, verify upgrade paths, and distinguish testing from validation.
- Create Handler Methods for Automated Tests: Create test codeunits, test methods, and test pages to test your application. To automate tests, create special handler methods for UI interactions.
- Create Test Runner Codeunits in AL: Learn how to create test runner codeunits in AL to manage the execution of test codeunits and integrate with test management or test reporting frameworks.
- Performance Toolkit extension: Test your extensions for performance regressions during the development process for Business Central apps.
- Test Codeunits and Test Methods in AL: Learn how to create test codeunits and test methods in AL, set the SubType property to Test, and use the different test method attributes in Business Central.
- Test Pages for Automated Business Central Tests: Use test pages in AL to automate Business Central page interactions, access fields and parts, filter records, invoke actions, and navigate data.
- Testing the application overview: Learn about how to use automated tests in Business Central
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #2342 Fix incremental builds poisoning buildMode-specific artifacts (#2337) (code change): “Fixed incremental builds in AL-Go that were corrupting buildMode-specific artifacts”
- #2343 RunTests action (code change): “new RunTests action that runs tests with AlTool”
- #2457 Fixing codeunit discovery on PowerShell 5 for RunTests action. (code change): “Fixed codeunit discovery in the RunTests action”
- #2479 Harden PR file validation and refresh E2E coverage (code change): “PR file validation in VerifyPRChanges.ps1 is tightened”
- #10055 Fix: migrating a document attachment deletes shared Tenant Media (code change): “Introduces three new unit tests verifying shared media protection”
- #10065 [Quality Management] Quality Inspection User assignment fixes (code change): “Tests for user assignment added to the misc test codeunit”
- #11637 [Master]- Create Documents on Recurring Billing ignores the Partner filter and fails when a vendor billing proposal exists (code change): “Create Documents on Recurring Billing now respects the Partner filter. New tests added”
- #11654 Repair and re-enable Expense Agent permission and posted-history tests (code change): “Expense Agent tests were repaired and re-enabled. The fixes cover permission checks”
- #11712 [Master] - Bug 624708: [Expense Management] Users sync - There should be a configuration wizard to ask if the Employees should be created behind if no match is found (code change): “Expense user synchronization gets new logic in the Expense User table. Tests were added”
- #11747 [master][Subscription Billing] Sales-Explode BOM fails for foreign-currency customers (code change): “Fixed a Sales Line does not exist error when exploding an Assembly BOM. Added test coverage”
- #12325 [Expense tests] Re-enable reviewed APIs and consolidate Expense fixes (code change): “Clean test codeunit execution is turned on”
- #12463 Fix Email upgrade writing during no-transaction upgrade test (code change): “Email Installer no longer re-registers email tables based on allowed-table”
- #12557 Implement first-party app authentication for Microsoft Fabric Export (code change): “tests are extended”
- #13558 Add logging table management during installation and upgrade processes (code change): “Updates the existing tests to match”
- #13622 [Main]- Edit in Excel insert fails on Price List Lines (Page 7001) — Unit of Measure Code validated before Product No. is set causing NavTestFieldException on Price Asset (Table 7003) (code change): “Added unit test UnitOfMeasureCodeOnInsertLineViaOData to verify the fix”
- #8924 [QM] Fixed overflow runtime error (code change): “Adds a regression test in the miscellaneous QM tests codeunit”
- #9293 [Bug][SubscriptionBilling] Process Usage Data Billing uses lines marked Processing Status = Error (currency mismatch) (code change): “Six new tests added covering the corrected behavior”
- #159 3 AL/BC testing patterns from an external BC testing expert’s blog (Luc van Vugt, fluxxus.nl) (code change): “AL testing patterns from an external BC testing expert’s blog”
- #280 knowledge(testing): ExpectedError must identify the intended error (code change): “ExpectedError must identify the intended error. The testing knowledge article”
- #292 Refactor review fixtures into article-local registrations (code change): “Review fixtures can now be registered in article-local JSON files”
- AL EventLens 0.1.6: the handler lens, and a fix that needed fixing (community post): “Handler lens shows test usage counts above handler functions such as MessageHandler, ConfirmHandler and PageHandler”
- AL Language extension for Microsoft Dynamics 365 Business Central version 16.2.1869542 (New version) (community post): “Testing enhancements enable HTTP request mocking with TestHttpRequestPolicy”
- Why do all my tests show up twice in the test explorer? (community post): “Tests show up twice in the VS Code test explorer when the pre-release AL Language extension”
- Your Tests All Pass. I Have Bad News. (community post): “Mutation testing is a technique that validates test quality by intentionally breaking code”
- Weekly Recap: August 7-14 (community post): “AL Runner shipped 85 PRs fixing emulation-to-real-BC divergences in rename propagation”
- Business Central 29: What’s New in Page Scripting? (community post): “Page Scripting integrates with CI/CD pipelines and complements AL automated tests”
- Agent Maron & waldo: Mission AL Runner (community post): “AL code tests outside Business Central using Rust and an in-memory database”
- South Coast Summit 2025 - AI-Driven Page Scripting: Practical Use Cases for Dynamics 365 (community post): “structured approach to using AI for creating and scaling page scripting test automation”
- Microsoft presents: Tests, dependencies, runners and evals for BC applications (video): “deterministic testing; propagated dependencies; application test library”
- Getting Started With Agent Testing: How to Write Agent Evals in AL (Part 2) (video): “Agent task flow mapping; multi-turn conversation testing; Test library data creation”
- What’s New: AL Language (2025 release wave 1) (video): “testing; http client; call stack; HTTP Client Handler for Testing”
- 20260504 - Super fast tests covering 100% of your code (video): “automated testing; code coverage; test patterns; environment configuration”
- What’s new: Testability Enhancements (2026 release wave 2) (video): “Data-driven Testing in AL”
- Introducing: How to Mock Outbound Http Calls for Easier Testing (2025 release wave 1) (video): “outbound http testing; mocking; HTTP client handler; test isolation; request interception”
- What’s New: AL Language (2025 release wave 2) (video): “AI Test Type; Required Test Isolation Property; Cancellation Token Propagation in VS Code”
- Getting Started With Agent Testing: Why Are Evaluations Important? (Part 1) (video): “Getting Started With Agent Testing: Why Are Evaluations Important”
- What’s New : AL-Go for GitHub on Quality and Testability (2025 release wave 1) (video): “Page Scripting Tests in AL-Go Workflow”
Business Central pages and reports
The pages, reports and queries this hub’s Learn pages name (ms.search.form, API reference), joined to the code by exact object id (data/index/docs-objects.json); a page shows the table it runs on.
Learn also names 9 objects with no object page: page/149000, page/149001, page/149003, page/149004, page/149005, page/149006, page/149007, page/149008, page/149009.
Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.
What Learn documents here 8 Learn pages
- learnApplication Testing Example to Test Purchase Invoice Discounts2026-08-24
- learnBusiness Central App Testing FAQ2026-11-27
- learnCreate Handler Methods for Automated Tests2026-08-24
- learnCreate Test Runner Codeunits in AL2026-08-24
- learnPerformance Toolkit extension2024-02-21
- learnTest Codeunits and Test Methods in AL2026-08-24
- learnTest Pages for Automated Business Central Tests2026-11-30
- learnTesting the application overview2025-09-30