Advertisement
Learnify_Rectify

Test Apex Triggers

Jun 21st, 2024
8,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | Source Code | 0 0
  1. Test Apex Triggers from (module - Apex Testing)
  2.  
  3.  
  4. -------------------------------------------------
  5. Name: TestRestrictContactByName
  6.  
  7. SOURCE CODE:
  8. @isTest
  9. private class TestRestrictContactByName {
  10. static testMethod void metodoTest()
  11. {
  12. List<Contact> listContact= new List<Contact>();
  13. Contact c1 = new Contact(FirstName='Francesco', LastName='Riggio' , email='[email protected]');
  14. Contact c2 = new Contact(FirstName='Francesco1', LastName = 'INVALIDNAME',email='[email protected]');
  15. listContact.add(c1);
  16. listContact.add(c2);
  17. Test.startTest();
  18. try
  19. {
  20. insert listContact;
  21. }
  22. catch(Exception ee)
  23. {
  24. }
  25. Test.stopTest();     
  26.     }  }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement