Bitta Apps
SolutionsPartnersAboutBlogPricingContact
Request a quote
Bitta Apps

Senior-led Business Central implementation, AL development, and Microsoft CSP licensing. Based in Corona, California. Remote-first across the U.S. and Canada, with onsite Southern California support by arrangement.

// services
  • Business Central partner
  • Implementation
  • AL Development
  • Integrations
  • Licensing & CSP
  • Support
  • QuickBooks migration
// industries
  • Distributors
  • Manufacturing
  • Retail
  • Healthcare
  • Non-Profit
  • Professional Services
// company
  • Solutions
  • Partners
  • Summit NA 2026
  • About
  • Careers
  • Blog
  • Pricing
  • Book a call
  • Contact
  • FAQ
// legal
  • Privacy
  • Terms
  • Cookies
  • EULA
info@bittaapps.com
LinkedIn
© 2026 · bittaapps.com · Microsoft Cloud Solution Providerinfo@bittaapps.com
    Back to blog

    // article

    AL Test Automation: Handlers, Isolation, and Upgrade-Safe Tests

    by Mohammad Nour Itani·Jul 20, 2026·Reviewed Aug 22, 2026 by Mohammad Nour Itani
    Business CentralAL Development
    AL DevelopmentBusiness Central ExtensionsTesting

    Automated AL tests protect more than individual procedures. They protect the business behavior that must survive extension refactors, dependency changes, and Business Central release waves. A useful test creates a known state, invokes the supported behavior, validates the outcome, and can run again without a person clicking through dialogs.

    Microsoft provides test codeunits, test runner codeunits, test pages, UI handlers, and assertion patterns for this purpose. Online production environments are not the place to execute automated tests; use sandboxes or container-based development environments according to Microsoft's documented limits.

    Test through a business boundary

    Prefer calling the same public codeunit or document operation used by production behavior. Testing a private helper can be useful, but a suite made only of helper tests can stay green while permissions, events, posting behavior, or integration boundaries fail.

    Use a clear arrange-act-assert structure:

    1. Initialize the environment and create only the data the case needs.
    2. Invoke one business behavior.
    3. Assert the result, side effects, and important absence of side effects.

    Use a Test codeunit

    // AL
    codeunit 50120 "BA Order Tests"
    {
        Subtype = Test;
    
        [Test]
        [HandlerFunctions('ConfirmReleaseHandler')]
        procedure ReleaseOrderAsksForConfirmation()
        var
            SalesHeader: Record "Sales Header";
            BAOrderRelease: Codeunit "BA Order Release";
        begin
            CreateSalesOrder(SalesHeader);
    
            BAOrderRelease.ReleaseWithConfirmation(SalesHeader);
    
            SalesHeader.Find();
            SalesHeader.TestField(Status, SalesHeader.Status::Released);
        end;
    
        [ConfirmHandler]
        procedure ConfirmReleaseHandler(Question: Text[1024]; var Reply: Boolean)
        begin
            Reply := true;
        end;
    
        local procedure CreateSalesOrder(var SalesHeader: Record "Sales Header")
        begin
            // Use the project's shared test library to arrange a valid order.
        end;
    }
    

    The example calls a codeunit owned by the extension rather than a base-application codeunit, so the confirmation that the handler exists for is certain to be raised. Naming a ConfirmHandler for a standard operation that may not prompt in a given version would fail the test for a reason unrelated to the behavior under test. The record is also re-read with Find before the assertion, so the check runs against stored data rather than a stale in-memory copy. Compile and execute the test against the target symbols during review.

    Handle every user interaction

    UI handlers replace messages, confirmations, menus, pages, reports, request pages, hyperlinks, notifications, and other interactions during an automated test. List each required handler in HandlerFunctions. Microsoft documents that every handler named in the attribute must be called at least one time in the test method, and that a test fails if a listed handler is never called. That makes unexpected changes to the interaction visible instead of silently ignored.

    A handler should verify the prompt or page state before returning a response. A confirmation handler that always replies true without checking the question can hide a new, unrelated confirmation.

    Keep test data deterministic

    Tests should leave the system in a known state and run in any order. Create records through shared test libraries, generate unique values when collisions matter, and avoid dependencies on a developer's existing company data. Use explicit work dates and setup values when the business result depends on them.

    Do not make tests depend on live external services. Put an interface or queue boundary around integrations and test the AL behavior with a controlled implementation. Exercise the real external contract in a separate integration environment.

    Test failure as carefully as success

    Positive tests prove that valid work succeeds. Negative tests prove that invalid work stops for the correct reason and leaves data correct. Microsoft documents AssertError for expected failures in test code. Validate meaningful error behavior, not an entire platform-generated string that can change harmlessly between versions.

    Build a risk-based suite

    • Core business rules and calculations
    • Posting and document state changes
    • Permissions and indirect-permission paths
    • Upgrade code and data conversion
    • Event subscriber applicability and idempotency
    • API validation and duplicate/retry behavior
    • Job queue retry and failure visibility
    • Coexistence with required dependency apps

    Use tests as release gates

    Run a fast suite on pull requests and a broader suite for release candidates. Archive results with the compiled package. Recompile and rerun against Business Central preview artifacts so deprecated symbols and behavioral changes are found before the customer's update window.

    A failed test is release evidence, not an inconvenience to rerun until it disappears. Record the defect, environmental cause, or reviewed expectation change.

    Give every regression test a business reason in its name or surrounding documentation. When requirements change, reviewers can then decide whether the implementation regressed or the expected result needs an intentional update, with that decision preserved in source control.

    Bitta Apps can add automated coverage to inherited extensions, build upgrade suites through AL development, and connect those gates to release-wave support and integration testing.

    // about this article

    Written by

    Mohammad Nour Itani

    Founder & Senior Business Central Developer · MB-820, MB-800

    Reviewed Aug 22, 2026 by

    Mohammad Nour Itani

    Founder & Senior Business Central Developer · MB-820, MB-800

    Sources

    Claims in this article were checked against the following on Aug 22, 2026.

    1. learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-testing-application
    2. learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-creating-handler-methods
    3. learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/attributes/devenv-handlerfunctions-attribute

    // next step

    Talk to a senior Business Central consultant, not a sales rep.

    Fixed-price proposal in writing within five business days of discovery.

    Request a quoteBook a call

    // keep reading

    Business Central Upgrade Readiness: After the August 31 Window

    An updated five-checkpoint checklist for Business Central teams checking update status, resolving blockers and verifying critical business workflows.

    QuickBooks vs Business Central for 3 to 10 Employees: Is ERP Too Much?

    A practical, honest framework for small teams deciding whether QuickBooks still fits or Business Central would create better operational control.

    Odoo vs Business Central: What Costs Less When Your Business Scales?

    Compare Odoo and Business Central using the same user roles, company structure, integrations, implementation scope and ongoing maintenance assumptions.