web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    THE Italian Profile Picture
    Microsoft Employee on at

    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.  

  • Suggested answer
    Mohana Yadav Profile Picture
    61,248 Super User 2026 Season 2 on at

    you can try HandlerFunctions

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

  • Suggested answer
    THE Italian Profile Picture
    Microsoft Employee on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 551 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 372 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 339 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans