You need to sign in to do that
Don't have an account?
hari0853701703454959
How to write test class for below coding
Hi,
how to write test class for below coding.Plz help asap
global class Batch_to_SentEmailNotify implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
string s='Blocked';
String query = 'Select Resort_Master__r.Name,Executive_Name__r.Email__c,Name_of_the_Guest__c,Company_Name__c,Block_Release_Date__c,Check_In__c,Check_Out__c,Total_Number_of_Rooms_Booked__c,Booking_Status__c,Source__c,Market_Segment__c,Executive_Name__r.Name FROM Non_Member_Booking_Request__c where Booking_Status__c=: s';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Non_Member_Booking_Request__c> scope)
{
for(Non_Member_Booking_Request__c c : scope)
{
system.debug('++++++++++++++system.today ++++++++++++++'+system.today());
string email = c.Executive_Name__r.Email__c;
if(email !=null && (system.today() == c.Check_In__c))
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email});
mail.setSubject('Booking Confirmation ');
mail.setHtmlBody('Dear Team <br/>'+'Namaste !!!!<br/>'+'Please find the attached payment details of below room reservation.<br/>'+'Please check and confirm the CV with updated payment details.<br/>'
);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
system.debug('@@@@@@@@@@@@@@@mail@@@@@@@@@@@@@@@'+mail);
}
}
}
global void finish(Database.BatchableContext BC)
{
}
}
Regards,
Hareesh
how to write test class for below coding.Plz help asap
global class Batch_to_SentEmailNotify implements Database.Batchable<sObject>
{
global Database.QueryLocator start(Database.BatchableContext BC)
{
string s='Blocked';
String query = 'Select Resort_Master__r.Name,Executive_Name__r.Email__c,Name_of_the_Guest__c,Company_Name__c,Block_Release_Date__c,Check_In__c,Check_Out__c,Total_Number_of_Rooms_Booked__c,Booking_Status__c,Source__c,Market_Segment__c,Executive_Name__r.Name FROM Non_Member_Booking_Request__c where Booking_Status__c=: s';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Non_Member_Booking_Request__c> scope)
{
for(Non_Member_Booking_Request__c c : scope)
{
system.debug('++++++++++++++system.today ++++++++++++++'+system.today());
string email = c.Executive_Name__r.Email__c;
if(email !=null && (system.today() == c.Check_In__c))
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] { email});
mail.setSubject('Booking Confirmation ');
mail.setHtmlBody('Dear Team <br/>'+'Namaste !!!!<br/>'+'Please find the attached payment details of below room reservation.<br/>'+'Please check and confirm the CV with updated payment details.<br/>'
);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
system.debug('@@@@@@@@@@@@@@@mail@@@@@@@@@@@@@@@'+mail);
}
}
}
global void finish(Database.BatchableContext BC)
{
}
}
Regards,
Hareesh
Just Insert the object that you are using in your Batch Class then after make the instance of your batch class like below
Batch_to_SentEmailNotify b = new Batch_to_SentEmailNotify ();
ID batchprocessid = Database.executeBatch(b);
then run your test class..Hope you will get the test coverage.
Cheers..!!!
Try for below link it will be helpful
http://www.infallibletechie.com/2013/09/test-class-for-batch-apex-in-salesforce.html
Regards,
Azusfdc