You need to sign in to do that
Don't have an account?
Øyvind Borgersen 10
Test class blob
Hi,
I'm creating a test class for a file creating apex class where I need some help in writing a test for the blob. Can someone help me with a test class for the following:
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname = 'test.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new list <string>();
toAddresses.add(emailAddress);
String subject = 'Videogram CSV';
//email.setsenderdisplayname ('test');
email.setOrgWideEmailAddressId(owea.get(0).Id);
email.setSubject(subject);
email.setToAddresses(toAddresses);
email.setPlainTextBody('test CSV ');
email.setFileAttachments(new Messaging.EmailFileAttachment[] {
csvAttc
});
Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {
email
I'm creating a test class for a file creating apex class where I need some help in writing a test for the blob. Can someone help me with a test class for the following:
Messaging.EmailFileAttachment csvAttc = new Messaging.EmailFileAttachment();
blob csvBlob = Blob.valueOf(finalstr);
string csvname = 'test.csv';
csvAttc.setFileName(csvname);
csvAttc.setBody(csvBlob);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new list <string>();
toAddresses.add(emailAddress);
String subject = 'Videogram CSV';
//email.setsenderdisplayname ('test');
email.setOrgWideEmailAddressId(owea.get(0).Id);
email.setSubject(subject);
email.setToAddresses(toAddresses);
email.setPlainTextBody('test CSV ');
email.setFileAttachments(new Messaging.EmailFileAttachment[] {
csvAttc
});
Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {
Shubham4462
What is the value of FinalStr here if it is a object records try to insert the record and pass the parameter in method it will automtically cover.
Anudeep (Salesforce Developers)
Posting here a sample test class for send email. Hope this helps