Testing
Testing in Business Central development covers writing AL test codeunits, test methods, handlers, test pages and test runners, plus running tests in VS Code, mocking HttpClient calls, performance testing, and page scripting for acceptance tests. It answers how to build, run and structure automated tests and what Marketplace apps should test.
- 11Learn pages
- 1videos
Path: Development > Development environment > Testing · tier official · system administration · narrative unreviewed (model text not yet checked)
Overview
This section explains how to test Business Central code and apps. It starts with an overview of application testing: test codeunits, test methods, test pages, UI handlers, test runner codeunits and the ASSERTERROR keyword. The overview is the best starting point.
Detailed pages cover each building block. Test codeunits and methods define attributes and isolation. Handler methods intercept messages, confirmations, pages and reports. Test pages simulate user interaction. Test runner codeunits manage unattended runs. An example page shows purchase invoice discount tests using test libraries and GIVEN-WHEN-THEN notation.
Other pages cover running and extending tests. These include running AL tests in Visual Studio Code with Test Explorer, mocking outbound HttpClient calls (on-premises only), the Performance Toolkit extension for workload and regression testing, and the page scripting tool for recorded acceptance tests. The App Testing FAQ describes what to test before Marketplace submission.
Key points
- Test codeunits and test methods use attributes such as TransactionModel and TestDataSource, and properties such as TestIsolation and TestHandlers.
- Handler methods (MessageHandler, ConfirmHandler, StrMenuHandler, PageHandler, ModalPageHandler, ReportHandler) replace user interaction in automated tests.
- Test pages let tests open pages, read or set fields, filter data, invoke actions and navigate records.
- Test runner codeunits use the TestRunner subtype with OnRun, OnBeforeTestRun and OnAfterTestRun triggers for unattended runs and result logging.
- Test Explorer in VS Code discovers and runs AL tests with run profiles, code coverage and debugger integration (version 28.0, 2026 release wave 1).
- HttpClient mocking uses HttpClientHandler and HandlerFunctions attributes and TestHttpRequestPolicy, and is available on-premises only.
- The Performance Toolkit extension lets ISVs and VARs simulate concurrent sessions, compare to baselines, and report through telemetry and Power BI.
- The page scripting tool records and replays web client interactions for acceptance testing, and bc-replay runs them in pipelines.
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.
- Mock outbound HttpClient web service calls during testing: Learn about how to test HttpClient web calls to external services without invoking the live/actual/remote service.
- Performance Toolkit extension: Test your extensions for performance regressions during the development process for Business Central apps.
- Run AL Tests in Visual Studio Code: Learn how to use the Test Explorer in Visual Studio Code to discover and run AL tests for Business Central directly from the IDE.
- 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
- Use the page scripting tool for acceptance testing: Learn how to record, edit, replay, and automate page scripts in Business Central to validate business processes and user acceptance tests.
Videos, posts and code changes
Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.
- #13598 Fix concurrent initialization of My Notifications (code change): “Added five deterministic regression tests covering all three table helpers”
- Business Central 2025 wave 2 (BC27): Record and edit easier with enhanced page scripting tool (community post): “page scripting tool, including improved script recording and editing”
- In Preview: User Acceptance Testing with the Page Scripting Tool (2024 release wave 1) (video): “user acceptance testing; page scripting tool; script recording and playback”
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 of 11 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
- learnMock outbound HttpClient web service calls during testing2025-03-17
- learnPerformance Toolkit extension2024-02-21
- learnRun AL Tests in Visual Studio Code2026-03-05
- learnTest Codeunits and Test Methods in AL2026-08-24