You need to sign in to do that
Don't have an account?
SFDC ROCK
Apex code Test class
How to write test class for below class
global void execute(Database.BatchableContext bc, List<opportunity> scope){
List<opportunity> ls=new list<opportunity>();
Map<Id,opportunity> update = new Map<Id,opportunity>();
for(opportunity oppty:scope){
if(oppty.abc=='P' && oppty.abc!='M'
&& oppty.createdby.profile.Name=='Custom: TCT'){
oppty.abc='M';
//Updated below opptyListUpdate List to update Map as to avoid duplicate values
update.put(oppty.Id,oppty);
ls.add(oppty);
break;
global void execute(Database.BatchableContext bc, List<opportunity> scope){
List<opportunity> ls=new list<opportunity>();
Map<Id,opportunity> update = new Map<Id,opportunity>();
for(opportunity oppty:scope){
if(oppty.abc=='P' && oppty.abc!='M'
&& oppty.createdby.profile.Name=='Custom: TCT'){
oppty.abc='M';
//Updated below opptyListUpdate List to update Map as to avoid duplicate values
update.put(oppty.Id,oppty);
ls.add(oppty);
break;
I have seen your Batch code and I am not able to understand what 'abc' is, that you use in your code.
So I created an 'abc__c' field on Opportunity of Picklist type and also created start and finish methods.
Batch Class:
*It Shows 100% code coverage for this batch class
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com