topic hubAdministration & Setupofficial - Microsoftunreviewed - model text not yet checked

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.

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

Videos, posts and code changes

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