+ Start a Discussion
sai kumar 433sai kumar 433 

write test class for program plz?

global class CaptureLastLoginDate implements Database.Batchable<sObject>{

        //This is the query that is passed to the execute method. .

        String ids = UserInfo.getUserId();
        String query = 'SELECT id,LastLoginDate__c FROM User ';

        global database.queryLocator start(Database.BatchableContext BC) {
             return database.getQueryLocator(query);
        //close start method
        global void execute(Database.BatchableContext BC, List<sObject> scope){
            List<Schema.User> u = new List<Schema.User> ();
            for(sObject s: Scope){
                Schema.User inv = (Schema.User)s;
                inv.LastLoginDate__c= inv.LastLoginDate__c;
            update u;

        global void finish(Database.BatchableContext sc){

Sandy GaliSandy Gali
This should help you - https://developer.salesforce.com/docs/atlas.en-us.apex_workbook.meta/apex_workbook/apex_batch_2.htm