• Kamalpreet Bhatia 3
  • NEWBIE
  • 0 Points
  • Member since 2016
  • Salesforce Developer
  • Dazeworks Pvt Lmtd.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
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();
	}
		

}