You need to sign in to do that
Don't have an account?
RAMANJINEYULU GOGULA
Test class for Schedulable Batch class
Class::
global class Rfleet_C2GFRScheduledBatchable_SCH implements Schedulable{
global void execute(SchedulableContext sc) {
//added by murugan
//If the model, the version already exists in the R-FLEET product object but isn’t present in C2G return then the ‘Active’ checkbox on Product object isn’t ticked anymore
list<Product2>updateActive=new list<Product2>();
list<Product2> lsprodinactive=[Select IsActive from Product2 where CountryCode__c='FR'];
for(Product2 prod:lsprodinactive){
if(prod.IsActive==true){
prod.IsActive=false;
updateActive.add(prod);
}
}
update updateActive;
Rfleet_C2GProductDetails_BATCH frBatch = new Rfleet_C2GProductDetails_BATCH(label.Rfleet_FranceLabel.touppercase());
ID batchprocessid = Database.executeBatch(frBatch ,1);
}
}
Test Class:
@isTest
public class Rfleet_C2GDEScheduledBatchable_SCH_TEST {
@isTest static void c2GDEScheduleTest(){
Product2 p2=new Product2();
p2.Name='TEST';
p2.IsActive=TRUE;
p2.CountryCode__c='DE';
insert p2;
test.startTest();
Rfleet_C2GDEScheduledBatchable_SCH rcs=new Rfleet_C2GDEScheduledBatchable_SCH();
Rfleet_C2GProductDetails_BATCH deBatch = new Rfleet_C2GProductDetails_BATCH(label.Rfleet_germanyCountryCode.touppercase());
String schedule='0 0 * * * ?';
System.schedule('TEST C2GDE', schedule, rcs);
//stem.scheduleBatch('deBatch','TEST C2GDE', 0,1);
test.stopTest();
}
}
Here everything is covering except " ID batchprocessid = Database.executeBatch(frBatch ,1); "
Can any1 answer it ?
global class Rfleet_C2GFRScheduledBatchable_SCH implements Schedulable{
global void execute(SchedulableContext sc) {
//added by murugan
//If the model, the version already exists in the R-FLEET product object but isn’t present in C2G return then the ‘Active’ checkbox on Product object isn’t ticked anymore
list<Product2>updateActive=new list<Product2>();
list<Product2> lsprodinactive=[Select IsActive from Product2 where CountryCode__c='FR'];
for(Product2 prod:lsprodinactive){
if(prod.IsActive==true){
prod.IsActive=false;
updateActive.add(prod);
}
}
update updateActive;
Rfleet_C2GProductDetails_BATCH frBatch = new Rfleet_C2GProductDetails_BATCH(label.Rfleet_FranceLabel.touppercase());
ID batchprocessid = Database.executeBatch(frBatch ,1);
}
}
Test Class:
@isTest
public class Rfleet_C2GDEScheduledBatchable_SCH_TEST {
@isTest static void c2GDEScheduleTest(){
Product2 p2=new Product2();
p2.Name='TEST';
p2.IsActive=TRUE;
p2.CountryCode__c='DE';
insert p2;
test.startTest();
Rfleet_C2GDEScheduledBatchable_SCH rcs=new Rfleet_C2GDEScheduledBatchable_SCH();
Rfleet_C2GProductDetails_BATCH deBatch = new Rfleet_C2GProductDetails_BATCH(label.Rfleet_germanyCountryCode.touppercase());
String schedule='0 0 * * * ?';
System.schedule('TEST C2GDE', schedule, rcs);
//stem.scheduleBatch('deBatch','TEST C2GDE', 0,1);
test.stopTest();
}
}
Here everything is covering except " ID batchprocessid = Database.executeBatch(frBatch ,1); "
Can any1 answer it ?
Do You got a chance to check the Test generator app from App Exchange please check the below link
Thanks
Rahul Kumar
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm