You need to sign in to do that
Don't have an account?

Different result test IDE and Developer Console
/** * Function attach file to email */ public PageReference attachFileToEmail() { // In case have file if(attachment.Name != null) { // Get parentID EmailTemplate parentTemplate = [SELECT Id FROM EmailTemplate LIMIT 1]; // Set ParentId and Description attachment.ParentId = parentTemplate.Id; try { // Insert file insert attachment; // Clear body file attachment.Body = null; if(attachment.Id != null) { uploadedAttachments.add(attachment); } } catch (DMLException e) { ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,UPDATE_FILE_FAILD_ERROR_MESSAGE)); } finally { attachment = new Attachment(); } } else { ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,NO_CHOSE_FILE_ERROR_MESSAGE)); } return null; }My function:
My unit test:
/** * attachFileToEmail test * Insert success */ @isTest static void AttachFileToEmailSuccessTestCase1() { // Create data Task[] results; BulkEmailSenderControllerTest mgr = new BulkEmailSenderControllerTest(); BulkEmailSenderController controller = new BulkEmailSenderController(); mgr.createEmailTemplateData(); // Create data controller.attachment.Name='Unit Test Attachment'; Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body'); controller.attachment.body = bodyBlob; controller.attachment.parentId = [SELECT Id FROM EmailTemplate LIMIT 1].Id; // Running test Test.startTest(); controller.attachFileToEmail(); Test.stopTest(); // Compare System.assertEquals(1, controller.uploadedAttachments.size()); }
When I run test in Eclipse, this unit test is pass . However on Developer Console Tool is failed with message (System.AssertException: Assertion Failed: Expected: 1, Actual: 0).
Please help my problem.
Make sure you ahev latestcode in your eclipse, simply take referesh from server and then chck the test coverage from eclipse and let me know if you still face the same error..
Thanks,
Sandeep
Please let us know if this will help you