You need to sign in to do that
Don't have an account?

Test class for .adderror
Hi all,
I have created a trigger that has 75% code coverage. I am unsure how to set an .adderror from my trigger. Dones anyone have a code sample of how this can be achieved?
Thanks
Trigger:
Test Class:
I have created a trigger that has 75% code coverage. I am unsure how to set an .adderror from my trigger. Dones anyone have a code sample of how this can be achieved?
Thanks
Trigger:
trigger PicklistLimitTrigger on Software_Assets__c(before insert,before update){ Integer count =[select count() from Software_Assets__c where Software_Product__c='Windows 7']; for(Software_Assets__c a:trigger.new){ if(count==3&&a.Software_Product__c=='Windows 7'){ a.addError('Please chose some other pick-list Values'); } } }
Test Class:
@isTest private class PickListLimitTriggerTest { static testMethod void PickListLimitTrigger() { Software_Assets__c sa = new Software_Assets__c(Asset_First_Recorded__c = date.today(), Asset_Status__c = 'Operational', Vendor__c = 'Microsoft', Software_Product__c = 'Windows 7'); insert sa; } }
All Answers
Replace your test call by this one
Regards
Subhash
Error: Compile Error: Method does not exist or incorrect signature: [LIST<Software_Assets__c>].adds(SOBJECT:Software_Assets__c) at line 7 column 5
Thanks
Thanks