Testing
Testing in Business Central covers writing automated AL tests (test codeunits, test methods, test pages, handler methods, test runners), a worked purchase invoice discount example, an app testing FAQ, and the Performance Toolkit extension for workload and regression testing.
- 8Learn pages
- 7videos
Path: Development > Extension lifecycle > Testing · tier official · system development · narrative reviewed (checked by Opus)
Overview
This section explains how to test Business Central extensions. It starts with an application testing overview that introduces test codeunits, test methods, test runner codeunits, test pages, UI handlers and the ASSERTERROR keyword, and gives best practices for automated, repeatable tests.
The detail pages follow from there. Test codeunits and test methods describe the attributes and properties that structure a test. Test pages simulate user interaction with pages. Handler methods intercept messages, confirmations, pages and reports so tests run without a user. Test runner codeunits run test codeunits unattended with pre- and postprocessing and result logging. The purchase invoice discount example ties these together using test libraries and GIVEN-WHEN-THEN notation.
For app-level questions, the FAQ covers what testing is expected, including version, country and upgrade testing. The Performance Toolkit extension is for ISVs and VARs who need to simulate workloads and check performance regressions. Start with the overview, then read the example.
Key points
- Test codeunits and test methods in AL use attributes such as TransactionModel and TestDataSource, plus the TestIsolation and TestHandlers properties; the page mentions runtime 16 and runtime 18.
- Handler methods include MessageHandler, ConfirmHandler, StrMenuHandler, PageHandler, ModalPageHandler and ReportHandler, so UI interactions need no user.
- Test runner codeunits use the TestRunner subtype with OnRun, OnBeforeTestRun and OnAfterTestRun triggers to run tests unattended and log results.
- Test pages simulate user actions: read or change fields, access subpages, filter data, invoke actions and navigate records.
- The purchase invoice discount example uses Library - Random, Library - Purchase, the Assert codeunit and GIVEN-WHEN-THEN notation.
- The FAQ covers complete coverage, automated and manual testing, country-specific testing, upgrade testing and Docker 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.
- 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.
- FAQ about Testing your Business Central App: Get answers to some of your questions about testing when you build an app for Dynamics 365 Business Central
- 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: This article explains the Test pages, their purpose and use.
- 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”
- #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”
- #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”
- 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”
- AL Runner: Run AL Unit Tests Without a BC Service Tier (community post): “AL Runner is a CLI tool that transpiles AL code to C# and executes unit tests”
- You don’t need the base app to run your unit tests (community post): “Unit tests for self-contained Business Central logic do not require the base application to run”
- Microsoft presents: Tests, dependencies, runners and evals for BC applications (video): “Tests dependencies runners and evals for BC applications”
- What’s new in AL and Tools (2026 release wave 2) (video): “Data-driven testing framework; Test handler interface for lifecycle hooks; Static call graph analysis”
- 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): “100% code coverage testing pattern; Fast automated testing framework”
- 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: Test Setup and Structuring (part 3) (video): “agent testing; test setup; data-driven tests; yaml configuration”
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
- learnCreate Handler Methods for Automated Tests2026-08-24
- learnCreate Test Runner Codeunits in AL2026-08-24
- learnFAQ about Testing your Business Central App2022-08-15
- learnPerformance Toolkit extension2024-02-21
- learnTest Codeunits and Test Methods in AL2026-08-24
- learnTest pages2022-08-12
- learnTesting the application overview2025-09-30