You need to sign in to do that
Don't have an account?
chaithaly gowda
Test class not covering start method of the batch class
Hi
I have a batch class 'TerritoryDetails' which has been scheduled in 'ScheduleTerritoryDetails'.
I have a test class 'TestScheduleTerritoryDetails'
public with sharing class TestLFDTerritoryScheduler {
@TestSetup
static void makeData(){
//Testdata created
}
static testmethod void test(){
Test.startTest();
ScheduleTerritoryDetails m = new ScheduleTerritoryDetails();
String hour = '0';
string minute = '30';
string sec = '0';
String sch = sec+ ' '+ minute+' '+ hour +' '+'* * ?';
String jobName = 'Update ';
id jobId = system.schedule(jobName, sch, m);
}
and in scheduler class , the batch class has been called.
TerritoryDetails b = new TerritoryDetails();
database.executeBatch(b, 3);
but when I execute the test class, it is covering 100% of scheduler class,but not covering the batch class.
Can someone please help in covering this batch class.
I have a batch class 'TerritoryDetails' which has been scheduled in 'ScheduleTerritoryDetails'.
I have a test class 'TestScheduleTerritoryDetails'
public with sharing class TestLFDTerritoryScheduler {
@TestSetup
static void makeData(){
//Testdata created
}
static testmethod void test(){
Test.startTest();
ScheduleTerritoryDetails m = new ScheduleTerritoryDetails();
String hour = '0';
string minute = '30';
string sec = '0';
String sch = sec+ ' '+ minute+' '+ hour +' '+'* * ?';
String jobName = 'Update ';
id jobId = system.schedule(jobName, sch, m);
}
and in scheduler class , the batch class has been called.
TerritoryDetails b = new TerritoryDetails();
database.executeBatch(b, 3);
but when I execute the test class, it is covering 100% of scheduler class,but not covering the batch class.
Can someone please help in covering this batch class.
Looks like batch job is not running. Try to put Test.stopTest(); after scheduled job statement.
Thanks