You need to sign in to do that
Don't have an account?
ArmanM
Help writing test code for public class
I have a class that uses email template with Visualforce, this would be used to send emails on opportunity. I have completed this class but I am having trouble writing a test that would pass (>75%). I am using this as reference:
https://help.salesforce.com/apex/HTViewSolution?id=000181102&language=en_US
This is my apex class:
Arman
https://help.salesforce.com/apex/HTViewSolution?id=000181102&language=en_US
This is my apex class:
public class emailHelper { // In a separate class so that it can be used elsewhere public Opportunity opp {get;set;} public User myUser { get;set;} public emailHelper(ApexPages.StandardController stdController) { opp = (opportunity)stdController.getRecord(); } User currentUser = [Select email from User where username = :UserInfo.getUserName() limit 1]; public PageReference sendEmail() { PageReference emailPage = new PageReference('/email/author/emailauthor.jsp'); Map<String, String> params = emailPage.getParameters(); params.put('p3_lkid',opp.ID); //email will be attached to the activity history of the opportunity where the button was clicked using the acct.ID params.put('template_id','00X28000000MfO6'); /// template ID of the email template to be shown goes here params.put('rtype','003'); params.put('p24', opp.CS_Resource__c); //Opportunity.CS_Resource__c showing in "Additional to" field params.put('p4', opp.Owner.Email); //cc the opportunity owner params.put('p5','email@email.com'); //email address showing in Bcc field params.put('new_template','1'); params.put('retURL',ApexPages.currentPage().getUrl()); //after send button is clicked, go back to the opportunity where the button was clicked return emailPage; } }Thank you,
Arman
All Answers
1)http://amitsalesforce.blogspot.com/search/label/Test%20Class
2) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
Please try below sample test class.
Let us know if this will help you
I tried the sample test, but the test was not successful. The following is what I tired:
Is there something I am doing wrong? How can I modify this test to run successfully with my emailHelper class. I really appreciate any response.
Thanks,
Arman
Please share that validation rule or try below code.
Yes, I do have the following validation rules on opportunity:
1-
Name: Actual_Close_Date_is_required_for_close
Error Condtion:
2-
Name: Lock_campaign_start_and_end_date
Error Condition:
3-
Name: Locked_Expected_Amount_And_Date
Error Condition:
4-
Name: RO_value_required
Error Condition: