You need to sign in to do that
Don't have an account?
sfdc dev 2264
Apex test class help
Hi ,
I need help for test class to cover the below class as follows, I have test class which is covering only 20% need help to cover above
Kindly help me pls
Thanks in Advance
I need help for test class to cover the below class as follows, I have test class which is covering only 20% need help to cover above
APEX CLASS : global with sharing class iDealPageRedirectExtn { public static Integer count{get; set;} public static Integer count2{get; set;} public static Integer count3{get; set;} public static Integer count4{get; set;} public iDealPageRedirectExtn(ApexPages.StandardController controller){ String accountId = ApexPages.CurrentPage().getParameters().get('id'); if(accountId!=null){ System.debug(count+' '+count2+' '+count3+' '+count4); count = 0; count2 = 0; count3 = 0; count4 = 0; count =[select count() from Agency_Info__c where Account__c= :accountId and Recordtype.Name='Distribution' limit 1]; count2 =[select count() from Agency_Info__c where Account__c=:accountId and PCC__c!='' and Recordtype.Name='GDS' limit 1]; count3 =[select count() from Agency_Info__c where Account__c in (select Primary_Account__c from Account_Relation__c where Related_Account__c=:accountId and Active__c=TRUE) and PCC__c!='' limit 1]; count4 =[select count() from Contract__c where Account__c=:accountId]; System.debug(count+' '+count2+' '+count3+' '+count4); } } }
Kindly help me pls
Thanks in Advance
APEX CLASS :
global with sharing class iDealPageRedirectExtn {
public static Integer count{get; set;}
public static Integer count2{get; set;}
public static Integer count3{get; set;}
public static Integer count4{get; set;}
public iDealPageRedirectExtn(ApexPages.StandardController controller){
Account account = (Account) controller.getRecord();
String accountId = Account.Id;
//String accountId = ApexPages.CurrentPage().getParameters().get('id'); // On Standard controller no need to take Id from getParameters method, use the Controller.getRecord instead.
if(accountId!=null){
System.debug(count+' '+count2+' '+count3+' '+count4);
count = 0;
count2 = 0;
count3 = 0;
count4 = 0;
count =[select count() from Agency_Info__c where Account__c= :accountId and Recordtype.Name='Distribution' limit 1];
count2 =[select count() from Agency_Info__c where Account__c=:accountId and PCC__c!='' and Recordtype.Name='GDS' limit 1];
count3 =[select count() from Agency_Info__c where Account__c in (select Primary_Account__c from Account_Relation__c where Related_Account__c=:accountId and Active__c=TRUE) and PCC__c!='' limit 1];
count4 =[select count() from Contract__c where Account__c=:accountId];
System.debug(count+' '+count2+' '+count3+' '+count4);
}
}
}
Test Class
===============
@isTest
private class iDealPageRedirectExtnTest {
@istest
private static void testmethod1()
{
Accountexp1.count = 0;
Accountexp1.count2 = 0;
Accountexp1.count3 = 0;
Accountexp1.count4 = 0;
Account ac = new Account();
ApexPages.StandardController std = new ApexPages.StandardController(ac);
Accountexp1 exp = new Accountexp1(std);
}
}