You need to sign in to do that
Don't have an account?
System.assertEquals on Email notification.
Hi,
public static void notifyResult()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddress(new String[] {mail@sample.com (mailto:{mail@sample.com)});
mail.setHtmlBody('TestBody');
mail.setSubject = 'Test Subject';
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
}
==========
Test Method
=========
private static testMethod void notifyResultTest()
{
//I am intializing Data Here.
Test.startTest();
instance.notifyResult();
//assert is passing here
system.assertEquals(1, Limits.getEmailInvocations());
Test.stopTest();
//assert is failing here.
system.assertEquals(1, Limits.getEmailInvocations());
}
*** But I am expecting assertion statement after stopTest. Can you please give some one answer.
Thanks
Venkat
public static void notifyResult()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddress(new String[] {mail@sample.com (mailto:{mail@sample.com)});
mail.setHtmlBody('TestBody');
mail.setSubject = 'Test Subject';
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
}
==========
Test Method
=========
private static testMethod void notifyResultTest()
{
//I am intializing Data Here.
Test.startTest();
instance.notifyResult();
//assert is passing here
system.assertEquals(1, Limits.getEmailInvocations());
Test.stopTest();
//assert is failing here.
system.assertEquals(1, Limits.getEmailInvocations());
}
*** But I am expecting assertion statement after stopTest. Can you please give some one answer.
Thanks
Venkat
This could be happening because the instance before the stopTest is not the same as the instance after it. Can you provide more details on what you are exactly expecting this for?
Thanks,
Shashank
Thanks for reply.
I am calling method using class name. like ClassName.notifyResult() in test method. Because that is static method. I am sending single email message in this method. so I am expecting '1' in email invocation. but why it is failing after Test.stopTest().
Regards
Venkat