I have written the following apex trigger which seems to work okay.
trigger Do_not_delete_activated_order_product on OrderItem (before delete) {
for (OrderItem o : trigger.old )
IF(o.Activation_Date__c < System.today()){
o.adderror('You cannot delete an order product which has already been activated.');
}
}
I now want to deploy this trigger from our developers sandbox to our production org.
Can someone please help me writing the test class and give me advice on how to deploy my trigger? (this is the first time I work with custom code)Best,Dorian1 answer
Check this - http://www.infallibletechie.com/2015/10/how-to-cover-adderror-in-trigger-in.htmlUse delete operation in the test class intstead of just create.