function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vicky rathivicky rathi 

System.ListException: List index out of bounds: -20

Hello Developers
  pls help me How to cover these line in test class I am try a lot but not success. MY test code is below
@isTest
private class MSDbugScheduleLogHistoryCl_Test {
  static testMethod void MSDbugScheduleLogHistoryCl_method() {
    MS_Sync_App__c oMSSyncApp = new MS_Sync_App__c(Name = 'WooCommerce');
    insert oMSSyncApp;
    
    MS_Connector__c oMSConnector = new MS_Connector__c(Name = 'WooCommArcs', Connector_Type__c = oMSSyncApp.Id);
    insert oMSConnector;
    
    String sConId = ApexPages.currentPage().getParameters().put('conTypeId', oMSSyncApp.Id);
    
    MS_Schedule__c oMSSchedule = new MS_Schedule__c(Name = 'Test', Connector__c = oMSConnector.Id);
    insert oMSSchedule;
    String sId = ApexPages.currentPage().getParameters().put('ScheduleId', oMSSchedule.Id);
    
    MS_Schedule_History__c oMSScheduleHistory = new MS_Schedule_History__c(MS_Schedule__c = oMSSchedule.Id);
    insert oMSScheduleHistory;
    String slogId = ApexPages.currentPage().getParameters().put('logid', oMSScheduleHistory.Id);
    
    MSDbugScheduleLogHistoryCl oMSDbugScheduleLogHistoryCl = new MSDbugScheduleLogHistoryCl();
    oMSDbugScheduleLogHistoryCl.sScheduleId = sId;
    oMSDbugScheduleLogHistoryCl.slogId = slogId;
    oMSDbugScheduleLogHistoryCl.sId = oMSScheduleHistory.Id;
    oMSDbugScheduleLogHistoryCl.beginning();
	oMSDbugScheduleLogHistoryCl.next();
	oMSDbugScheduleLogHistoryCl.previousRecord();
	oMSDbugScheduleLogHistoryCl.last();
	oMSDbugScheduleLogHistoryCl.getDisableNext();
    oMSDbugScheduleLogHistoryCl.getDisablePrevious();
	oMSDbugScheduleLogHistoryCl.Previous();
    oMSDbugScheduleLogHistoryCl.Mapping(); 
    oMSDbugScheduleLogHistoryCl.closePopup();
    oMSDbugScheduleLogHistoryCl.showPopup();
    System.assert(oMSSchedule.Id != null);
  }
}

How to cover these line in test class
SaurabhGupta_SaurabhGupta_
It is not very clear as this is not full oce but looks like you do not have huge set of record in test class so that it can go to next record or last record.
Please ceate good test data.
vicky rathivicky rathi
@Saurabh Gupta
Thanks for you reply.
But I stuck how to create the same in testclass or do some changes in controller.