Can any one help me in increasing code coverage .for the below class and test class.
Class:
global class Clear_Territory_Flag_Batch implements Database.Batchable<sObject> {
global String sql;
global Database.QueryLocator start(Database.BatchableContext BC) {
sql='select id,Territory_Update_Falg__c from opportunity where
Territory_Update_Falg__c=true and lastmodifieddate=today';
return Database.getQueryLocator(sql);
}
global void execute(Database.BatchableContext BC, List<SObject> objs) {
List<Opportunity> Opptys=new List<Opportunity>();
for(Opportunity o:(List<Opportunity>)objs){
o.Territory_Update_Falg__c=false;
Opptys.add(o);
}
if(Opptys.size()>0){
OpportunityTriggerHandler.skipTriggerProcessing = true;
update Opptys;
OpportunityTriggerHandler.skipTriggerProcessing = false;
}
}
global void finish(Database.BatchableContext BC) {
}
}
Test Class:
@isTest(SEEALLDATA=TRUE)
public class TestClear_Territory_Flag_Batch {
static testMethod void testMethod1()
{
List<Opportunity> st=new List<Opportunity>([Select id , Name , Territory_Update_Falg__c from Opportunity where Territory_Update_Falg__c = true ]);
for(integer i=0;i<1500;i++) {
Opportunity t=new Opportunity();
t.Territory_Update_Falg__c = true;
//t.id='0000000123';
st.add(t);
}
Database.BatchableContext bc;
Clear_Territory_Flag_Batch obj =new Clear_Territory_Flag_Batch();
//st=obj.start(b);
obj.execute(bc,st);
obj.finish(bc);
}
}
Aucun commentaire:
Enregistrer un commentaire