You need to sign in to do that
Don't have an account?
viswanadham A
How to cover the excute method in test class ? below is my test class .
Hi ,
Here i have paste my batch apex and test class but excute method is not coverd. how to i can cover the in test class. pls help me.
Regards,
Viswa
Here i have paste my batch apex and test class but excute method is not coverd. how to i can cover the in test class. pls help me.
global class R3_deleteQuoteWrapper implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database.BatchableContext BC){ String Query = 'Select id from Quote_Wrapper__c where CreatedDate < LAST_N_MONTHS:3'; return Database.getQueryLocator(Query); } global void execute(Database.BatchableContext BC, List<Quote_Wrapper__c> scope){ delete scope; } global void finish(Database.BatchableContext BC){ } }
@istest public class R3_deleteQuoteWrapper_test { static list<Quote_Wrapper__c> Quote = new list<Quote_Wrapper__c>(); static testmethod void testdata() { Quote_Wrapper__c QC=new Quote_Wrapper__c(); //QC.Name='testing'; QC.CurrencyType__c='USD'; insert QC; Test.startTest(); R3_deleteQuoteWrapper R3data=new R3_deleteQuoteWrapper(); Database.BatchableContext bc; Database.executeBatch(R3data); Test.stopTest(); } }
Regards,
Viswa
Step 1:
Create a csv file with header values having field api name and include created datetime field in csv file.
CSV file could be as below (you can include all the required fields if needed). Important point to note here is the date format for datetime field. Datetime field should be in the format of YYYY-MM-DDThh:mm:SS You will also need to include rest other required fields in csv file. Just ensure the header of csv file holds field api name.
Step 2:
Create a public static resource and load the csv file created in step 1.
Step 3:
Create a test class as below (assuming static resource name is QuoteWrapperLoad) This should help you test your batch class.
Mark this as best answer to help others if it solves your problem
Let us know if this will help you