function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Zaki KZaki 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 =[0].SVMXC__Case__c];
 Attachment[] insertAttList = new Attachment[]{};
         for(Attachment a: [select id, name, body from Attachment where ParentId =[0].SVMXC__Case__c])
               Attachment att = new Attachment(name =, body = a.body, parentid =[0].id);
       if(insertAttList.size() > 0)
            insert insertAttList;
subramanyam subbu 7subramanyam subbu 7
simple  create reference for ur class in test class.
Rashi Garg 30Rashi Garg 30
Try creating test class with following code

static testMethod void testAttachments() {
Case cse=new Case();
insert cse;

Attachment attach=new Attachment();
attach.Name='Unit Test Attachment';
Blob bodyBlob=Blob.valueOf('Unit Test Attachment Body');
insert attach;

List<Attachment> attachments=[select id, name from Attachment where];
SVMXC__Service_Order__c svmxOrder = new SVMXC__Service_Order__c(SVMXC__Case__c =;
insert svmxOrder;

System.assertEquals(1, attachments.size());