You need to sign in to do that
Don't have an account?
sfdc18
test class
How to write test class for trigger which compare older and newer valuee
trigger GetAvailability on Case (before update) { Boolean oooFlag; Set<ID> ids = Trigger.newMap.keyset(); ID oId; List<Case> caseList = [Select Id, Status, OwnerId from Case where Id in : ids]; for(Case c : caseList) { oId = c.OwnerId; } for (Case c : Trigger.New) { Case oldCase = Trigger.oldMap.get(c.Id); Boolean oldStatus = oldCase.Status.equals('Closed'); Boolean newStatus = c.Status.equals('New'); if(oldStatus && newStatus) { Map<Id, boolean> Map1 = GlobalClass.getAvailability(oId); for (Id id : Map1.keySet()) { oooFlag = Map1.get(id); System.debug('===oooFlag ' + oooFlag); break; } if(!oooFlag){ c.OwnerId = 'idtyt3RTGBhtu7u'; } } } }
Hi,
You can create a test case record/records and then update them with the values which you have mentioned in the code so the conditions will meet to cover the code.
Thanks,
Pratik