web
You’re offline. This is a read only version of the page.
close
Skip to main content
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
    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,949 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,132

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 3,615

#3
Sumit Singh Profile Picture

Sumit Singh 2,912

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans