You need to sign in to do that
Don't have an account?
How to cover trigger on sObject ContentDocument?
Hi,
I have created trigger on the sObject ContentDocument (before delete) and contentVersion (before insert, after insert). We want to create test class for these triggers. While inserting ContentVersion we are getting 'FIELD_CUSTOM_VALIDATION_EXCEPTION' error. For contentDocument we have tried to fetch exising ContentDocument using SOQL and tried to delete it, but it does't work. Please help me to write correct test method for contentVersion and ContentDocument.
Thanks
I have created trigger on the sObject ContentDocument (before delete) and contentVersion (before insert, after insert). We want to create test class for these triggers. While inserting ContentVersion we are getting 'FIELD_CUSTOM_VALIDATION_EXCEPTION' error. For contentDocument we have tried to fetch exising ContentDocument using SOQL and tried to delete it, but it does't work. Please help me to write correct test method for contentVersion and ContentDocument.
Thanks
and secondly testclass is nothing but just it will verify your code and cover it .
While inserting record through testclass , the trigger will fire and execute, verify your trigger completely , you will come to know from where you get the exception,
All Answers
I think you have written any custom validation rule on ContentVersion , and while inserting data through test class ,
you are not following those validation , that is the reason , you are getting exception .
To avoid this , you can enter the data in such way that will not hit the validation or else you can deactivate validation rule , so you will not get any exception while running test class.
Regards
Sagarika
Thanks for replaying, but I havent written any custom validation rule on ContentVersion
Thanks
and secondly testclass is nothing but just it will verify your code and cover it .
While inserting record through testclass , the trigger will fire and execute, verify your trigger completely , you will come to know from where you get the exception,