You need to sign in to do that
Don't have an account?
Devmen
system.assertion failed
hi,
i have a test class.It is throwing error System.Assertexception
the result.success is getting false.how can i resolve this error
thanks
i have a test class.It is throwing error System.Assertexception
Lead newLead = new Lead(); newLead.LastName='TestName'; newLead.Company = 'TestCompany'; newLead.Email='test@test.com'; newLead.Status ='Open'; newLead.Cc__c='test@test.com'; newLead.Description='Subject:TextBody'; insert newlead; Messaging.InboundEmail email = new Messaging.InboundEmail() ; Messaging.InboundEnvelope env = new Messaging.InboundEnvelope(); email.plainTextBody = 'teset'; email.fromAddress = 'test@test.com'; email.subject = 'Test Lead'; // email.ToAddress ='test@gmail.com'; CreateLeadExample edr = new CreateLeadExample(); edr.handleInboundEmail(email,env); Test.startTest(); Messaging.InboundEmailResult result = edr.handleInboundEmail(email, env); System.assert(result.success, 'Error processing email...'); Test.stopTest(); Lead [] leadDb = [SELECT Id FROM Lead where LastName=:email.FromAddress]; // System.assertEquals (1, leadDb.size(),'Lead was not inserted'); System.debug('Size'+leadDb.size()); attachment.body = blob.valueOf('my attachment text'); attachment.fileName = 'text'; email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment }; Attachment attach=new Attachment(); attach.Name='Test'; Blob bodyBlob=Blob.valueOf('Testing Body of Attachment'); attach.body=bodyBlob; insert attach;
the result.success is getting false.how can i resolve this error
thanks
What value you are getting in debug?
Result.success should give you true or false not a string.
debug it and change the assertion value in test class.