Install and run the Test Toolkit

Completed

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.

Screenshot of the Test Tool page with results of automated tests.

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.