In situations like these, put your custom notification send logic into a separate class - e.g.
Then, at test time, construct a mock version of the
MockCustomNotificationSender with the same signature as your
The mock simply counts how many times it is called in a static variable (or, if using
ApexMocks, it will count for you)
Then, inject the mock into the runtime version of the code-under-test. Finally, execute the code-under-test.
Your mock can also throw exceptions as part of dependency-injected constructor parameters.
You don't really need to know if the
send method works as SFDC will take care of that - you should be more interested in whether you tried to send the notification and how many times
For another take on custom notifications, see the andyinthecloud blog