Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How can I do automated testing in business central for app source

(5) ShareShare
ReportReport
Posted on by 188
Can anyone can elaborate the whole process that how can I do automated testing for deploying the extension on app source?
  • Suggested answer
    YUN ZHU Profile Picture
    84,278 Super User 2025 Season 1 on at
    How can I do automated testing in business central for app source
    Hi, Did you test it on the cloud?
    As of now, some of the test apps are not available in SaaS Sandbox. It is recommended to test in Docker version.
    More details:
     
    Hope this helps as well.
    Thanks.
    ZHU
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    684 on at
    How can I do automated testing in business central for app source

    Hi Alina,

    I’ve put together a sample project showcasing a full setup for automated testing and validation of Business Central extensions for AppSource submission.

    It includes:

    • A sample extension with automated tests
    • An Azure DevOps pipeline configuration to manage the validation process


    https://github.com/jeffreybulanadi/D365-BusinessCentral-Community-Solutions/tree/main/AL-Extensions/AppSourcePipelineValidation

    If you find this helpful, feel free to mark my answer as verified and suggested!

    Cheers,

  • Suggested answer
    Khushbu Rajvi. Profile Picture
    17,377 Super User 2025 Season 1 on at
  • Alina Fahim Ibrahim Profile Picture
    188 on at
    How can I do automated testing in business central for app source
    I am unable to download symbols with test runner dependency in app.json. What should I do? 
  • Suggested answer
    Sohail Ahmed Profile Picture
    3,285 on at
    How can I do automated testing in business central for app source
    This might give you a hint to find your solution
     
     
     
    Mark below checkbox to make this answer Verified if it helps you.
  • Suggested answer
    YUN ZHU Profile Picture
    84,278 Super User 2025 Season 1 on at
    How can I do automated testing in business central for app source
  • Gerardo Rentería García Profile Picture
    19,674 Most Valuable Professional on at
  • Suggested answer
    RockwithNav Profile Picture
    7,059 on at
    How can I do automated testing in business central for app source
    Normally I use to define this and then take care of all the error messages.
     

    {

        "al.enableCodeAnalysis": true,

        "al.codeAnalyzers": ["${AppSourceCop}","${CodeCop}","${UICop}"],

        "al.ruleSetPath": "./alrules.json",

    }

     

    Blog - rockwithnav.wordpress.com/
    Twitter - https://twitter.com/RockwithNav

    Facebook - https://facebook.com/rockwithnav/

     
     
     
     
     
  • Suggested answer
    Saif Ali Sabri Profile Picture
    2,211 Super User 2025 Season 1 on at
    How can I do automated testing in business central for app source
    To implement automated testing in Dynamics 365 Business Central for an extension you plan to publish on AppSource, you need to follow a structured process that aligns with Microsoft’s requirements and best practices. Below is a complete solution for setting up, writing, and executing automated tests for your Business Central extension.

    ✅ Solution: End-to-End Automated Testing for AppSource Deployment
    1. Understand the AppSource Submission Requirements
    AppSource submissions must include automated tests using AL test codeunits. Microsoft will run your test app in their validation pipeline.
    Key requirements:
    • Include a separate test app (.app file).
    • Tests must cover your extension’s core functionality.
    • Tests must execute without manual intervention.

    2. Set Up Your Development Environment
    Prerequisites:
    • Visual Studio Code
    • AL Language extension
    • Docker (with Business Central sandbox images)
    • Business Central container helper (PowerShell module)
    • Test libraries from Microsoft
    Steps:
    powershell     CopyEdit
    # Pull and run a testable container
    New-BcContainer -accept_eula `
                    -containerName "testcontainer" `
                    -artifactUrl (Get-BcArtifactUrl -type Sandbox -country "w1") `
                    -auth NavUserPassword `
                    -includeTestToolkit `
                    -updateHosts

    3. Create a Separate Test App
    Structure your solution:
    bash    CopyEdit
    MyExtension/
    ├── app/
    │   └── source/
    │       └── ... (main app AL files)
    ├── test/
    │   ├── app.json
    │   ├── launch.json
    │   └── source/
    │       └── Codeunit50100.MyTests.al
    • The test app depends on:
      • Your main app (app.json → dependencies)
      • Microsoft’s test libraries (TestLibraries)
    json   CopyEdit
    "test": "true",
    "dependencies": [
      {
        "id": "YourExtension-ID",
        "publisher": "YourPublisher",
        "name": "YourAppName",
        "version": "1.0.0.0"
      },
      {
        "id": "23de40a6-dfe8-4f80-80db-d70f83ce8caf",
        "publisher": "Microsoft",
        "name": "Test Runner",
        "version": "22.0.0.0"
      }
    ]

    4. Write Test Codeunits Using AL
    Use Microsoft’s test framework (Assert, TestRunner, etc.)
    Example test codeunit:
    al   CopyEdit
    codeunit 50100 "My Test Codeunit"
    {
        Subtype = Test;

        [Test]
        procedure TestMyFunctionality()
        var
            MyRecord: Record "My Table";
        begin
            MyRecord.Insert();
            Assert.IsTrue(MyRecord.IsInserted(), 'Record should be inserted.');
        end;
    }
    Tips:
    • Use [Test] attribute
    • Use Assert methods to validate behavior
    • Create tests that do not require UI interaction

    5. Run and Validate Tests Locally
    Use Docker and the Test Runner to execute tests:
    powershell   CopyEdit
    Invoke-NavContainerCodeunit -containerName "testcontainer" `
                                -tenant default `
                                -codeunitId 50100 `
                                -credential $credential
    Or use the AL Test Tool in VS Code:
    • Ctrl+Shift+P > AL: Run Test Tool
    • Select test codeunits and run them

    6. Prepare the .app Files for Submission
    For AppSource submission:
    • One .app file for your main extension
    • One .app file for your test app
    🔹 Package the test app with only what's needed to test your extension – no test data, no dependencies outside of Microsoft libraries and your app.

    7. Submit to AppSource (Partner Center)
    • Upload both .app files
    • Complete the technical validation steps
    • Microsoft will automatically run your tests in a containerized environment
    You must ensure:
    • All tests pass without errors
    • No user prompts
    • No failures on fresh install/uninstall scenarios

    🔍 Additional Tips
    • Use TestPage objects to simulate user interactions if needed.
    • Validate positive and negative scenarios.
    • Clean up test data within each test.

    ✅ Summary
    Step Description
    1 Understand AppSource test requirements
    2 Set up BC test container with test toolkit
    3 Create a separate test app project
    4 Write AL test codeunits using [Test] methods
    5 Run and validate tests locally
    6 Package .app files (main + test)
    7 Submit to AppSource with passing tests

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans