You need to sign in to do that
Don't have an account?

Testclass For Extension
HI
i am new to salesforce
i am getting only 50% code coverage only
please write the test class for this controller class
Here my code:
public class Partner_For_Account {
public list<Partner_For_Account__c>partners{set;get;}
public string partnerAccountid{set;get;}
private final Account acct;
public integer rowno{set;get;}
public list<Partner_For_Account__c> PartnerAccount { get; set; }
public id Accountid;
//string id= Apexpages.currentPage().getparameters().get('id');
public Partner_For_Account(Apexpages.standardcontroller controller){
Accountid=controller.getid();
System.debug('Accountid'+Accountid);
system.debug('partnerAccountid'+partnerAccountid);
partners=new list<Partner_For_Account__c>();
PartnerAccount = new list<Partner_For_Account__c>();
Partner_For_Account__c p=new Partner_For_Account__c();
p.Account__c=Accountid;
partners.add(p);
system.debug('partners'+partners);
system.debug('Name'+'Malli');
PartnerAccount =[select id,Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where Account__c =:Accountid];
}
public void addrow(){
partners.add(new Partner_For_Account__c(Account__c=Accountid));
}
public void deleterow(){
rowno=integer.valueOf(apexpages.currentPage().getparameters().get('index'));
partners.remove(rowno);
}
public void savepartner(){
insert partners;
partners=new list<Partner_For_Account__c>();
Partner_For_Account__c p=new Partner_For_Account__c();
p.Account__c=Accountid;
partners.add(p);
refreshing();
}
public void deletepartnerAccount()
{
system.debug('partnerAccountid'+partnerAccountid);
Partner_For_Account__c PartnerAccounts=[select Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where id=:partnerAccountid];
delete PartnerAccounts;
refreshing();
}
public void refreshing(){
PartnerAccount =[select Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where Account__c =:Accountid];
}
}
i am new to salesforce
i am getting only 50% code coverage only
please write the test class for this controller class
Here my code:
public class Partner_For_Account {
public list<Partner_For_Account__c>partners{set;get;}
public string partnerAccountid{set;get;}
private final Account acct;
public integer rowno{set;get;}
public list<Partner_For_Account__c> PartnerAccount { get; set; }
public id Accountid;
//string id= Apexpages.currentPage().getparameters().get('id');
public Partner_For_Account(Apexpages.standardcontroller controller){
Accountid=controller.getid();
System.debug('Accountid'+Accountid);
system.debug('partnerAccountid'+partnerAccountid);
partners=new list<Partner_For_Account__c>();
PartnerAccount = new list<Partner_For_Account__c>();
Partner_For_Account__c p=new Partner_For_Account__c();
p.Account__c=Accountid;
partners.add(p);
system.debug('partners'+partners);
system.debug('Name'+'Malli');
PartnerAccount =[select id,Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where Account__c =:Accountid];
}
public void addrow(){
partners.add(new Partner_For_Account__c(Account__c=Accountid));
}
public void deleterow(){
rowno=integer.valueOf(apexpages.currentPage().getparameters().get('index'));
partners.remove(rowno);
}
public void savepartner(){
insert partners;
partners=new list<Partner_For_Account__c>();
Partner_For_Account__c p=new Partner_For_Account__c();
p.Account__c=Accountid;
partners.add(p);
refreshing();
}
public void deletepartnerAccount()
{
system.debug('partnerAccountid'+partnerAccountid);
Partner_For_Account__c PartnerAccounts=[select Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where id=:partnerAccountid];
delete PartnerAccounts;
refreshing();
}
public void refreshing(){
PartnerAccount =[select Partner__c,Partner_Manager__c,Partner_Segment__c,Partner_Sales_Person__c ,Account__c from Partner_For_Account__c where Account__c =:Accountid];
}
}
Use this App and generate Test class yourself
https://appexchange.salesforce.com/listingDetail?listingId=a0N3A00000EFozgUAD
Hope this helps you!
Best Regards,
Rakesh Thota.