Write a trigger to count number of contacts associated with an account with it's test class.
Whenever new contact is created for an Account update the field Number of contacts(a custom field of type Integer/Number)with the number of contacts. It should also update the count when contact is deleted /removed from Account. The respective count would be increased/Decreased accordingly. ....Trigger.... trigger CountContacts on Contact (after insert, after update, after delete) { list<contact> conList = new list<contact>(); list<account> accList = new list<account>(); set<ID> accIDs = new set<ID>(); if(trigger.isInsert || trigger.isUpdate) { for(contact con : trigger.new) { if(String.isNotBlank(con.accountId)) { accIds.add(con.accountId); } } } if(trigger.isDelete) { for(contact con : trigger.old) { accIDs.add(con.AccountId); } } if(accIDs.size()>0) { conList = [select name, id, acc...