Skip to main content

Notifications

Community site session details

Community site session details

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

Automated testing of Notifications

(0) ShareShare
ReportReport
Posted on by 115

Hi,
Can anyone guide me how can I test notifications that appear on Role Center Page through automated testing?

After Notification.send() is called nothing happens next. Is there any way that I can catch the notification message ?
thanks

  • Suggested answer
    THE Italian Profile Picture
    on at
    RE: Automated testing of Notifications

    You could also extract all the zip files from test toolkit for baseapp from DVD.

    These are in this directory

    \applications\BaseApp\test

    When you have all of them extracted, you could search in VS Code for SendNotificationHandler 

    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods/devenv-sendnotificationhandler-attribute

    and be inspired by the code written by Microsoft in these test codeunits. 

    Below just a screenshot snippet

    pastedimage1591351826636v1.png

    and just an example with codeunit 138961 "BC O365 Payment Tests"

        [SendNotificationHandler]
        [Scope('OnPrem')]
        procedure NotificationHandler(var TheNotification: Notification)Boolean
        begin
            if StrPos(TheNotification.Message, 'The last email about this document could not be sent'<> 0 then
                exit;
            if TheNotification.Message = TaxSetupNeededMsg then
                exit;
            Error(UnhandledNotificationErr, TheNotification.Message);
        end;

        [SendNotificationHandler(true)]
        [Scope('OnPrem')]
        procedure VerifyNoNotificationsAreSend(var TheNotification: Notification)Boolean
        begin
            Assert.Fail('No notification should be thrown.');
        end;
    Thanks to Mohana to remind the Handler usage.
  • Suggested answer
    Mohana Yadav Profile Picture
    60,232 Super User 2025 Season 1 on at
    RE: Automated testing of Notifications

    you can try HandlerFunctions

    docs.microsoft.com/.../devenv-handlerfunctions-attribute

  • Suggested answer
    THE Italian Profile Picture
    on at
    RE: Automated testing of Notifications

    When developing automated tests, there are external UI actions unavailable.

    Notifications, might be an example. After SEND, the notification is displayed in the UI and if these has been specified with an action (ADDACTION) then users might have or not performed the action to click into the link.

    This action is a UI action like, e.g. invoking an external dialog to upload a file, and test toolkit should not be able to catch it.

    Maybe you could think of adding another separate testing module to mimic the action that would have been performed with the ADDACTION. That is the only solution that I could see, personally.  

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

Announcing the Engage with the Community forum!

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 953

#2
YUN ZHU Profile Picture

YUN ZHU 921 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 602

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans