topic hubAdministration & Setupofficial - Microsoftreviewed - checked by Opus

Testing

Testing in Business Central covers writing AL tests (test codeunits, methods, test pages, handlers, test runners), running them in Visual Studio Code, mocking HttpClient calls, performance testing, and UI acceptance testing with page scripting. It answers how-to and setup questions for testing apps.

Path: Development > Development environment > Testing · tier official · system administration · narrative reviewed (checked by Opus)

Overview

The section describes how to build and run automated tests for Business Central apps. It starts with an overview of application testing, then goes into the building blocks: test codeunits and test methods, test pages that simulate user interaction, handler methods that intercept messages, confirmations, pages, reports and notifications, and test runner codeunits that control execution and logging.

Further pages cover running tests. Test Explorer in Visual Studio Code discovers and runs AL tests with run profiles and code coverage. The page scripting tool records and replays web client interactions for acceptance testing, and the Performance Toolkit extension simulates workloads to find performance regressions. A separate page explains how to mock outbound HttpClient calls during tests, which is available on-premises only. A worked example for purchase invoice discounts shows the pieces together, and an FAQ lists what testing an app needs.

Start with the testing overview, then the test codeunits and test pages articles, and use the purchase invoice discount example as a template. Go to the FAQ for testing expectations such as country and upgrade testing.

Key points

  • Test codeunits and test methods use attributes such as TransactionModel and TestDataSource, plus the TestIsolation and TestHandlers properties.
  • Handler methods (MessageHandler, ConfirmHandler, StrMenuHandler, PageHandler, ModalPageHandler, ReportHandler) replace user interaction in automated tests.
  • Test runner codeunits use the TestRunner subtype with OnRun, OnBeforeTestRun and OnAfterTestRun triggers for unattended runs and result logging.
  • Test pages simulate user actions: reading and changing fields, filtering, invoking actions, and navigating records.
  • Mocking outbound HttpClient calls uses HttpClientHandler and HandlerFunctions attributes and request policies; it is available on-premises only.
  • Test Explorer in Visual Studio Code supports test discovery, run profiles, code coverage and debugger use; the page is tagged with 2026 release wave 1 (version 28.0).
  • The page scripting tool records and replays web client interactions, supports validation, conditional and wait steps and parameters, and runs in pipelines with bc-replay.
  • The Performance Toolkit lets ISVs and VARs simulate concurrent sessions, compare to baselines, and report through telemetry and Power BI.

Learn pages

Videos and posts

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

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

Show 3 more