Install and run the Test Toolkit
Microsoft delivers a Test Toolkit with Business Central that allows you to manage and run automated tests. The results are collected and displayed in a Test Tool page. This page is part of the Test Toolkit.
Before version 15 of Business Central (which was the November 2019 release), you needed to import a (.fob) file that was included on the DVD to install the Test Toolkit. With version 15, Microsoft replaced the old Test Toolkit with a new Test Toolkit extension, rewritten with AL code. This toolkit can now be installed like any other extension. You can find the toolkit on the DVD in the applications\TestFramework folder.
However, it is recommended to use Docker containers to run your tests. This is ideal to integrate in your build pipelines and run the tests automatically on every build. The NavContainerHelper has support for the Test Toolkit built in automatically.
When you create a new container via the New-BCContainer Cmdlet, you can specify the option -includeTestToolkit to install the toolkit during the creation of the container or run the Import-TestToolkitToBCContainer function to import it afterwards. The NavContainerHelper automatically checks which version of Business Central is installed within the container and imports the correct Toolkit.
If you do not specify any other option, the command will install:
- the testing framework (the Test Tool page and code to run tests)
- Test Libraries
- standard Test Codeunits for standard objects
You can also specify the -includeTestLibrariesOnly, which will only import the Test Libraries, but not the standard Test Codeunits. The -includeTestFrameworkOnly will only install the testing framework.
New-BCContainer -accept_eula
-imageName mcr.microsoft.com/businesscentral/onprem:ltsc2019
-containerName MyDevContainer
-updateHosts
-includeTestToolkit
This command will publish and install five apps. In the output of the Docker creation script, you can see the different apps listed.
...
Ready for connections!
Reading CustomSettings.config from MyDevContainer
Creating Desktop Shortcuts for MyDevContainer
Publishing C:\Applications\TestFramework\TestLibraries\Any\Microsoft_Any.app
Synchronizing Any on tenant default
Installing Any on tenant default
App successfully published
Publishing C:\Applications\TestFramework\TestLibraries\Assert\Microsoft_Library Assert.app
Synchronizing Library Assert on tenant default
Installing Library Assert on tenant default
App successfully published
Publishing C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app
Synchronizing Test Runner on tenant default
Installing Test Runner on tenant default
App successfully published
Publishing C:\Applications\System Application\Test\Microsoft_System Application Test Library.app
Synchronizing System Application Test Library on tenant default
Installing System Application Test Library on tenant default
App successfully published
Publishing C:\Applications\BaseApp\Test\Microsoft_Tests-TestLibraries.app
Synchronizing Tests-TestLibraries on tenant default
Installing Tests-TestLibraries on tenant default
App successfully published
TestToolkit successfully imported
Container MyDevContainer successfully created
The same is true for the Import-TestToolkitToBCContainer function.
Import-TestToolkitToBCContainer -containerName MyDevContainer
Before you can install the AL Test Suite, you should verify that your license will allow you to install it. Use your development license when you create a container.
Environment testing support and limitations
The extent to which you can run automated tests depends on your Business Central solution type and environment. The following list provides an overview.
Online
Production - Running tests isn't allowed because it might have an adverse effect on your business. Testing can incidentally invoke external systems, like CDS, PayPal, and web hook subscriptions. Invoking these systems may slow down the solution for other users or cause data corruption.
Sandbox - You can use a sandbox environment to run tests manually to verify functionality on an environment. Running a large number of tests or tests that take a long time (more than 15 minutes per test method) isn't allowed. It's recommended that you don't run tests more than one or two hours a day.
On-premises
- Production - For Business Central on-premises, running automated tests is only possible with a Partner license or a license that includes the Application Builder module. You can disable the ability to run tests by turning off Enable Test Automation (TestAutomationEnabled) on the Business Central Server instance. For more information, see Configuring Business Central Server - Development settings.
Container-based development environment
- This setup should be the default environment for running large number of tests or setting up CI/CD gates. For more information, see Running a Container-Based Development Environment.
