You need to sign in to do that
Don't have an account?

Need help in writting Test Classes
Hi,
I have a test class that deletes custom object record at the end of day if the value of Grand Total field is 0.
Grand Total field is a roll up field, and is calculated basis the line item value.
Here is my batch class.
global class ProductInterestDeleteBatch implements Database.Batchable<sObject>,Schedulable{
global void execute(SchedulableContext sc){
ProductInterestDeleteBatch bc = new ProductInterestDeleteBatch();
database.executeBatch(bc);
}
global Database.QueryLocator start(Database.BatchableContext bc){
return database.getQueryLocator([SELECT Id FROM Product_Interest__c WHERE Grand_Total__c=0]);
}
global void execute(Database.BatchableContext bc,List<Product_Interest__c> productInterestList){
if(!productInterestList.isEmpty()){
database.delete(productInterestList,false);
}
}
global void finish(Database.BatchableContext bc){
}
}
I need help in writting test class for the same.
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Please check below code
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com