You need to sign in to do that
Don't have an account?
Zaki K
test cases
Hi all.
here is my code . how can i achieve 100% code coverage for this Trigger?
trigger CopyAttachments on SVMXC__Service_Order__c(after insert)
{
//Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c];
Attachment[] insertAttList = new Attachment[]{};
for(Attachment a: [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c])
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}
}
here is my code . how can i achieve 100% code coverage for this Trigger?
trigger CopyAttachments on SVMXC__Service_Order__c(after insert)
{
//Attachment[] attList = [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c];
Attachment[] insertAttList = new Attachment[]{};
for(Attachment a: [select id, name, body from Attachment where ParentId = :Trigger.new[0].SVMXC__Case__c])
{
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0)
{
insert insertAttList;
}
}
static testMethod void testAttachments() {
insert cse;
Attachment attach=new Attachment();
attach.Name='Unit Test Attachment';
Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
attach.body=bodyBlob;
attach.parentId=cse.id;
insert attach;
List<Attachment> attachments=[select id, name from Attachment where parent.id=:cse.id];
SVMXC__Service_Order__c svmxOrder = new SVMXC__Service_Order__c(SVMXC__Case__c = cse.id);
insert svmxOrder;
System.assertEquals(1, attachments.size());