
1 resposta

Seems like you have hardcoded a User ID in the batch. (It's a bad practise.)Keep the User ID field as a static variable and before calling the batch class assign it the class, else you may provide a default value. This will ensure your class runs.While Writting test class, make sure to create records inside 'System.runas(user)' and assign the user ID to the batch class before calling it. Global Class WL_ValidationProcess1Batch implements Database.Batchable<SObject>{
public static String usrId ;
global Database.QueryLocator start(Database.BatchableContext BC){
if(usrId==null){
usrId = 'xxxxxxxxxxxxxxxxxx';
}
return Database.getQueryLocator(Query);
}
/*
Test Class
*/
WL_ValidationProcess1Batch.userid = 'TestUserID';
WL_ValidationProcess1Batch bint = new WL_ValidationProcess1Batch ();
database.executeBatch(bint);