You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Need halp in Test class
Hi guyz,
I have written a Test class for Batch clas with the help of google. but I could able to cover only 14%. In debug log My Execute method was not covered. Any help?
My Class :
Test class :
Thanks,
I have written a Test class for Batch clas with the help of google. but I could able to cover only 14%. In debug log My Execute method was not covered. Any help?
My Class :
global class batchVATenureUpdate implements Database.Batchable<AggregateResult> { global Iterable<AggregateResult> start(Database.BatchableContext info) { return new AggregateVAtenureIterable(); } global void execute(Database.BatchableContext info, List<AggregateResult> accva ) { List<Our_VA__c> ourvalist = new List<Our_VA__c>(); map<string,Decimal> mapva = new map<string,Decimal>(); integer i; for(AggregateResult av : accva) { mapva.put(string.valueof(av.get('VA__c')),(Decimal)av.get('daycount')); } map<Id,Our_VA__c> ourva = new map<Id,Our_VA__c>(); List<Our_VA__c> ourva1 = new List<Our_VA__c>(); ourva1 = [select id,VA_Tenure_Active_Clients__c,VA_Tenure_Cancellation__c,Account_Number__c,BonusCount__c,Name,ClientCount__c,LoanCount__c,test__c from Our_VA__c];// where id IN:vaids]; for(Our_VA__c a : ourva1) { ourva.put(a.id,a); string idva = string.valueof(a.id); if(mapva.containskey(idva) == true) { a.VA_Tenure_Active_Clients__c = mapva.get(idva); ourvalist.add(a); } } update ourvalist; } global void finish(Database.BatchableContext BC) { } }
Test class :
@isTest public class TestvaTenureactiveclients1 { public static testmethod void batchVATenureUpdate() { our_va__c v1 = new our_va__c(); v1.name = 'v1'; insert v1; Account_VA__c accva = new Account_VA__c(); accva.Account__c = a1.id; accva.VA__c = v1.id; accva.Status__c = 'Active'; accva.Type__c = 'Full Time'; accva.VA_start_Date__c = Null; insert accva; Test.StartTest(); list<account_va__c> accvax=new list<account_va__c>(); accvax.add(accva); upsert accvax; list<our_va__c> ourvax=new list<our_va__c>(); ourvax.add(v1); upsert ourvax; batchVATenureUpdate objBatch = new batchVATenureUpdate(); Database.executeBatch(objBatch); Test.StopTest(); } }
Thanks,
AggregateVAtenureIterable is what you are returning from your start methos ,where is that code ??
Hi Manoj,
Its a Class that I am using to get values with Group by method..
Plz see below.
Thanks for youre help. :)Did you get any solution for this. I am facing the same problem.