topic hubAL Developmentofficial - Microsoftunreviewed - model text not yet checked

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.

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

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 Learn pages