You need to sign in to do that
Don't have an account?
Kamalpreet Bhatia 3
In the Above code it is not covering a if statements. Here timer__c is formula field .
Test Class:
I have written a test class, it is only covering 68% percent of the code. Please help to increase the code coverage
try{ for(Case c : caseList){ if(c.Timer__c >= 10){ c.IsEscalated = true; c.Status = 'Escalated'; caseUpdateList .add(c); system.debug(c); } } if(caseUpdateList .size()>0){ update caseUpdatelist ; system.debug(' case is Escalated in 10 minutes'); } } catch(exception ex){ system.debug(' case is not updated, it is now working according the criteria'); }
In the Above code it is not covering a if statements. Here timer__c is formula field .
Test Class:
@isTest(SeeAllData = true) private class CaseEscalationTest { private static testMethod void caseEscalationTestMethod() { case c = new case(); c.status = 'New'; c.origin = 'Phone'; c.Type = 'Status of specimen'; c.IsEscalated = false; insert c; c = [SELECT Status,Origin,Type,Timer__c FROM case WHERE Id = :c.Id]; //Datetime yesterday = Datetime.now().addDays(-1); //Test.setCreatedDate(c.Id, yesterday); case c1 = new case(); c1.status = 'New'; c1.origin = 'Phone'; c1.Type = 'Status of specimen'; c1.IsEscalated = true; insert c1; Test.startTest(); scheduleOneMinute som = new scheduleOneMinute(); system.Schedule('Specimen Cases', '0 1 11 ? * *', som); Test.stopTest(); } }
Insert case with the Timer__c with greater than 10 value and insert the case , if still doesn't gets then create a another method and try to insert the case which satisfies the conditon and run it.
Ex:
if it helps you mark it as Best Answer
Thanks ,
karthik
Check the formula for Timer__c field and insert case according to that.
Hope this helps you.
Thanks,
Sukanya Banekar