Run AL Tests from Visual Studio Code
Microsoft Dynamics 365 Business Central now allows developer to run automated tests direclty from Visual Studio Code. This feature was introduced in the 2026 release wave 1 (BC28). It significantly improves the developer workflow.
Why This Matters
Until now, running automated tests required switching context e.g. using web client or waiting for the CI/CD pipelines. This slowed down developers workflows.
With built-in test excecution in Visual Studio Code, developers can:
- Run tests without leaving the development environment
- Get fast feedback on code changes
- Debug failing tests faster
- More easly implement test-driven-development (TDD)
Prerequisites
If you are reading this while version 28 is still in preview, make sure that the AL Language Extension is set to pre-release version.
Official documentation:
- https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-extension-development
- https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-testing-application
- https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/whatsnew/preview-feature-details#run-al-tests-from-visual-studio-code

You will notice a new Testing icon in Visual Studio Code.
In this section, you can find all automated test available in the current workspace. They are grouped by applicaton and test codeunits.
![]()
Running test in AL
For each codeunit or individual test, there are three available methods:
Run Test
This option runs selected codeunits and/or tests

You can also run test directly from the AL file context.

Debug Test
This option allows you to debug the selected test.

Run Test with Coverage
It creates coverage.json file used for testing code coverage.
Tested functions
Tested functions include an additional indicator showing the latest result. You can also run tests directly from the function level, which is a very convenient feature.

Results
Test results are displayed in multiple places:
- Test Results section after you click on the test
- Testing panel on the left side
- For each codeunit and test directly in the AL file.

Fix Test using AI
You can try the Fix Test Failure feature, where AI suggests changes to help test pass.

Code
// Welcome to your new AL extension.// Remember that object names and IDs should be unique across all extensions.// AL snippets start with t*, like tpageext - give them a try and happy coding!
codeunit 50100 Test{ Subtype = Test;
[Test] // Scenario: Create a sales order and verify that the bill-to customer is the same as the sell-to customer by default. procedure CreateSalesOrder() var Customer: Record Customer; Customer2: Record Customer; SalesHeader: Record "Sales Header"; LibrarySales: Codeunit "Library - Sales"; SalesAdditionalFunctions: Codeunit "Sales Additional Functions"; Assert: Codeunit Assert; begin // given LibrarySales.CreateCustomer(Customer); LibrarySales.CreateCustomer(Customer2); LibrarySales.CreateSalesHeader(SalesHeader, "Sales Document Type"::Order, Customer."No.");
// when SalesAdditionalFunctions.ChangeBillTo(SalesHeader, Customer2."No.");
// then Assert.AreEqual(SalesHeader."Sell-to Customer No.", SalesHeader."Bill-to Customer No.", 'Bill-to is different than Sell-to'); end;
[Test] // Scenario: Create a sales invoice and verify that the bill-to customer is the same as the sell-to customer by default. procedure CreateSalesInvoice() var Customer: Record Customer; Customer2: Record Customer; SalesHeader: Record "Sales Header"; LibrarySales: Codeunit "Library - Sales"; SalesAdditionalFunctions: Codeunit "Sales Additional Functions"; Assert: Codeunit Assert; begin // given LibrarySales.CreateCustomer(Customer); LibrarySales.CreateCustomer(Customer2); LibrarySales.CreateSalesHeader(SalesHeader, "Sales Document Type"::Invoice, Customer."No.");
// when SalesAdditionalFunctions.ChangeBillTo(SalesHeader, Customer."No.");
// then Assert.AreEqual(SalesHeader."Sell-to Customer No.", SalesHeader."Bill-to Customer No.", 'Bill-to is different than Sell-to'); end;}codeunit 50101 "Sales Additional Functions"{ procedure ChangeBillTo(var SalesHeader: Record "Sales Header"; BillToCustomerNo: Code[20]) begin SalesHeader.Validate("Bill-to Customer No.", BillToCustomerNo); SalesHeader.Modify(); end;
}Conclusion
Running automated tests directly in Visual Studio Code is a major improvement for developers. It increase productivity and shortens feedback loop. It easier to adpot test-driven-development (TDD).
It has real impact on code quality and delivery speed.