You need to sign in to do that
Don't have an account?
ezdhanhussain
Coverage struck at 63 can any one suggest possible way to cover this method
public pagereference sendEmail(){ engine = new ParsingEngine(); engine.originalData = mergedTemplate; engine.editableAreas = areas; engine.replaceForSend(); mergedTemplate = engine.parsedData; myEmail__c email = new myEmail__c(); try { //Since it is a callout, do the sending first. Then do all the DB tasks, which are really only done for tracking purposes. CWS.Email emailObject = new CWS.Email(); emailObject.fromAddress = emailFrom; emailObject.toAddress = recipient.Email; emailObject.subject = emailSubject; emailObject.body = mergedTemplate; emailObject.pairs = new List<CWS.Pair>(); attachlist =[select id,name,body from attachment where id IN : attachlist1]; //Process the attachments for (attachment att : attachlist) { CWS.Pair file = new CWS.Pair(); file.key = att.name; file.value = EncodingUtil.base64Encode(att.body); emailObject.pairs.add(file); att.body = null; } cws.sendEmail(emailObject); attachlist.clear(); email.id = emailid; email.From__c = emailFrom; email.To__c = recipient.Email; email.Subject__c = emailSubject; email.Body__c = mergedTemplate; System.debug('==================111 email.id:'+ email.id); System.debug('==================112 email.From__c:'+ email.From__c); System.debug('==================113 email.To__c:'+ email.To__c); System.debug('==================114 email.Subject__c:'+ email.Subject__c); System.debug('==================115 email.Body__c:'+ email.Body__c); system.debug('before upsert:::::::'); upsert email; system.debug('After upsert:::::::'+email); attachment a = new attachment(); a.parentid=email.id; a.name ='email template'; a.body = blob.valueof(mergedtemplate); upsert a; system.debug('attached template in sobjecte::::::::'+a); //inserting in email sobject to track sent history Email__c em = new email__c(); em.Type__c ='Sent'; em.Date_Time__c = system.now(); em.Email__c =recipient.Email; if(experienceid.startswith('5')){ system.debug('Before assgining id case::'+experienceid); em.experience__c = experienceid; system.debug('after assgining id case::'+em.experience__c); } else{ system.debug('Before assgining id promise::'+experienceid); em.promise_date__c = experienceid; system.debug('after assgining id promise::'+em.promise_date__c); } em.Assigned_to__c=recipient.ownerid; if(action !='' && action!=null){ em.name =action +'{Ref:'+''+Casenumber+'}' ; } else { em.name ='Follow Up to Your Request'+'{Ref:'+''+Casenumber+'}'; } system.debug('Before attachments'); insert em; list<attachment> newAttachments = new list<attachment>(); attachment emailAtt = new Attachment(); emailAtt.ParentId = em.id; emailAtt.Name = 'Emailpdf'; emailAtt.Body = blob.valueof(mergedTemplate); emailAtt.contenttype = 'pdf'; newAttachments.add(emailAtt); if (newAttachments.size() > 0) { try{ insert newAttachments; system.debug('attachments insert in email successfull::::::::::::::'); } catch(exception ex){ system.debug('attachments insert in email error::::::::::::::'); } Utils.addMessage(ApexPages.Severity.CONFIRM, Label.Email_Success); msg = true; emailSent = true; getattlist(); } } catch (Exception e) { system.debug('error catch block::::::::::::::'); Utils.addMessage(ApexPages.Severity.ERROR, Label.Email_error+''+e.getmessage()+e.getLineNumber() ); msg = true; emailsent = true; } }
Sonam_SFDC
When you run this test class in the developer console - you will get the lines being tested by the test method and the lines which are yet outside the test methid execution- this would make it easier for you to identify and write the next set of test methods to target code with is uncovered yet.
ezdhanhussain
HI Sonam_SFDC Thank you for a quick reply.. i have done what you said and above are the lines which are Uncovered.. This is the only method which is not getting code coverage ???