You need to sign in to do that
Don't have an account?
sfdc007
Test class help needed for Batch class
Hi,
I have a batch class where i am trying to write the test class for it
Help me how to write the test class for it
Thanks in Advance
I have a batch class where i am trying to write the test class for it
Help me how to write the test class for it
MY BATCH CLASS : global class MillisecondBatchConvertController implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { // SOQL Query to fetch the values of hours , minutes and days String query = 'SELECT Hours__c, Minutes__c, Days__c FROM PS_TF_Status_Track__c'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<PS_TF_Status_Track__c> scope) { for(PS_TF_Status_Track__c currPS: scope) { long hoursToMilliSeconds = Integer.Valueof(currPS.Hours__c != null ? currPS.Hours__c * 3600000 : 0); long minToMilliSeconds = Integer.Valueof(currPS.Minutes__c != null ? currPS.Minutes__c * 60000 : 0); long daysToMilliSeconds = Integer.Valueof(currPS.Days__c != null ? currPS.Days__c * 86400000 : 0); // Enter your custom field to sum all three fields values. currPS.Total_Milliseconds__c = hoursToMilliSeconds + minToMilliSeconds + daysToMilliSeconds; } update scope; } global void finish(Database.BatchableContext BC) { } }Kindly help me pls
Thanks in Advance
Try with below code and let me know if it helps
Thanks
Mnaoj
All Answers
Try with below code and let me know if it helps
Thanks
Mnaoj
https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_batch_1.htm
https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_batch_2.htm
The first part is building the testing data. In your case, you needs to build some record to PS_TF_Status_Track__c object.
The second part is to run the batch class. Use
The last part is to verify the result.