You need to sign in to do that
Don't have an account?
Robin Shira
How to add ApexPages.addmessage in test class
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, 'Please enter a valid email'));
return null;
how to add in test class.
Thanks!!!
return null;
how to add in test class.
Thanks!!!
Hello Robin,
You can test Like this.
System.assert (ApexPages.getMessages().get(0).getDetail() == 'Please enter a valid email');
To know more Please refer this Link - http://salesforce-evershine-knowledge.blogspot.com/2012/07/testing-apexpagesmessage-in-controller.html
I hope it helps you.
Kindly let me know if it helps you and please mark as Best Answer.
Thanks and Regards,
Biswojeet
Hi Robin
Please send me the code.
Thanks,
Hello Robin
Please try to create a record according to your "else if" condition. Means which "payment_method" should be 'Credit Card' And related opportunity's Credit_Hold should be True.
Then run the test class.
To check error use
System.assert (ApexPages.getMessages().get(0).getDetail() == 'Please enter a valid email');
If you are not getting please send me your full class or full method. Then I will send you the test class code.
Thanks,