could anyone help in writing a test class for the following code 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,LastLoginDate__c FROM User '; global database.queryLocator start(Database.BatchableContext BC) { System.debug(query); 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; u.add(inv); System.debug(u); } update u; } global void finish(Database.BatchableContext sc){ } } **Update** Thank you for the replying. Here is the test method I'm using: @IsTest(SeeAllData=true) Private class LastLogintest { String ids = UserInfo.getUserId(); // Making the assumption that at least one user will match this. Better to assign to list and check that has at least one record. Schema.User testUser = [Select Id, LastLoginDate__c from User where LastLoginDate != null limit 1]; // Set it to anything other than LastLoginDate so we can tell it has changed. testUser.LastLoginDate__c = null; update testUser; Test.startTest(); CaptureLastLoginDate captureBatch = new CaptureLastLoginDate(); // Modify the query here so we only get our one testing user of interest captureBatch.query = 'SELECT id, LastLoginDate,LastLoginDate__c FROM User where Id =: testUser.Id limit 1'; ID batchprocessid = Database.executeBatch(captureBatch); Test.StopTest(); User afterBatchUser = [Select Id, LastLoginDate, LastLoginDate__c from User where Id =:testUser.Id limit 1]; System.AssertEquals(afterBatchUser.LastLoginDate, afterBatchUser.LastLoginDate__c); } > ERROR:Error: Compile Error: unexpected token: 'testUser.LastLoginDate__c' at line 10 column 3