Created
June 17, 2020 13:38
-
-
Save techb/85181dfe5e420b3ba2dc43e6c8153cd6 to your computer and use it in GitHub Desktop.
Unit test for sending emails in Apex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public class TestEmailSend { | |
@isTest | |
static void testTheEmail(){ | |
Test.startTest(); | |
// the method we're testing | |
// https://gist.github.com/techb/7519e95bac3caa2b8adb3f65d2dc2dc8 | |
EmailSend.sendEmail('[email protected]'); | |
// we assert buy what govener limits say | |
Integer invocations = Limits.getEmailInvocations(); | |
Test.stopTest(); | |
System.assertEquals(1, invocations, 'Email has not been sent'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment