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

Problem with Test class & COde coverage
public class jointactionplancon {
//variable declaration
public id i ;
public List<Business_Plan_Response__c> bp{get; set;}
public Business_Plan_Response__c bpr{get; set;}
public List<Business_Plan_Proposal__c> bprlst{get; set;}
public integer num{get; set;}
public integer num1{get; set;}
public Business_Plan_Proposal__c bpprop{get; set;}
//constructor
public jointactionplancon ()
{ bpr=new Business_Plan_Response__c();
i=Apexpages.currentpage().getparameters().get('id');
bprlst= new List<Business_Plan_Proposal__c>();
bprlst=[SELECT id, Proposal_Txt__c,Action_Txt__c,Priority_Num__c,Business_Plan_SFID__c, Review_Txt__c FROM Business_Plan_Proposal__c WHERE Business_Plan_SFID__c=:i ORDER BY Priority_Num__c asc limit 2 ];
bpprop=new Business_Plan_Proposal__c();
bp= new list<Business_Plan_Response__c>();
bp=[SELECT id,Question_Txt__c,Display_Order_Num__c,Response_Txt__c FROM Business_Plan_Response__c WHERE Business_Plan_SFID__c=:i ORDER BY Display_Order_Num__c asc ];
}
//this method is to Add a row in list
public PageReference Add_Row()
{ //bprlst= new List<Business_Plan_Proposal__c>();
for(integer i=0; i<num; i++){
bprlst.add(new Business_Plan_Proposal__c());}
return null;
}
public PageReference Add_Row1()
{
for(integer i=0; i<num1; i++){
bp.add(new Business_Plan_Response__c());}
return null;
}
//to pull list of Active Campaigns based on vob
public list<Campaign> getcamp(){
list<Campaign> ca= new list<Campaign>();
ca=[select Name from Campaign where Type='VOB' and IsActive=true limit 10 ];
return ca;
}
// Saving & Cancel the record and navigating to view page
public PageReference saverec() {
//this loop for updating bp response
for( Business_Plan_Response__c bprs: bp){
if(bprs.id!=null){
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
update bpr;}
else{
bprs.Business_Plan_SFID__c=i;
insert bprs;
}
}
//this loop for updating bp proposal
for(Business_Plan_Proposal__c bpps:bprlst){
if(bpps.id!=null)
{
bpprop.id=bpps.id;
bpprop.Proposal_Txt__c=bpps.Proposal_Txt__c;
bpprop.Action_Txt__c=bpps.Action_Txt__c;
bpprop.Review_Txt__c=bpps.Review_Txt__c;
update bpprop;
}else{
bpps.Business_Plan_SFID__c=i;
insert bpps;
}
}
return null;
}
public PageReference cancel() {
return null;
}
}
--------------------------------------
Test class:-
--------------------------------------
@istest
private class testjointActionplan{
static testMethod void testjointActionplan()
{
Business_Plan__c bp= new Business_Plan__c( name='test',Account_SFID__c='00130000011kO2F');
insert bp;
system.assertnotEquals(bp,null);
Business_Plan_Response__c bprs= new Business_Plan_Response__c();
Business_Plan_Response__c bpr= new Business_Plan_Response__c();
bpr.Business_Plan_SFID__c=bp.id;
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
insert bpr;
Business_Plan_Proposal__c bplst= new Business_Plan_Proposal__c();
bplst.Business_Plan_SFID__c=bp.id;
insert bplst;
jointactionplancon con= new jointactionplancon ();
con.Add_Row();
con.Add_Row1();
con.saverec();
con.getcamp();
con.cancel() ;
}
}
Am gettin 65% code coverage could any one help me on this
Thanks In advance
Which lines of code is not covered?...............
public class jointactionplancon {
//variable declaration
public id i ;
public List<Business_Plan_Response__c> bp{get; set;}
public Business_Plan_Response__c bpr{get; set;}
public List<Business_Plan_Proposal__c> bprlst{get; set;}
public integer num{get; set;}
public integer num1{get; set;}
public Business_Plan_Proposal__c bpprop{get; set;}
//constructor
public jointactionplancon ()
{ bpr=new Business_Plan_Response__c();
i=Apexpages.currentpage().getparameters().get('id'
);
bprlst= new List<Business_Plan_Proposal__c>();
bprlst=[SELECT id, Proposal_Txt__c,Action_Txt__c,Priority_Num__c,Business_Plan_SFID__c, Review_Txt__c FROM Business_Plan_Proposal__c WHERE Business_Plan_SFID__c=:i ORDER BY Priority_Num__c asc limit 2 ];
bpprop=new Business_Plan_Proposal__c();
bp= new list<Business_Plan_Response__c>();
bp=[SELECT id,Question_Txt__c,Display_Order_Num__c,Response_Txt__c FROM Business_Plan_Response__c WHERE Business_Plan_SFID__c=:i ORDER BY Display_Order_Num__c asc ];
}
//this method is to Add a row in list
public PageReference Add_Row()
{ //bprlst= new List<Business_Plan_Proposal__c>();
for(integer i=0; i<num; i++){
bprlst.add(new Business_Plan_Proposal__c());}
return null;
}
public PageReference Add_Row1()
{
for(integer i=0; i<num1; i++){
bp.add(new Business_Plan_Response__c());}
return null;
}
//to pull list of Active Campaigns based on vob
public list<Campaign> getcamp(){
list<Campaign> ca= new list<Campaign>();
ca=[select Name from Campaign where Type='VOB' and IsActive=true limit 10 ];
return ca;
}
// Saving & Cancel the record and navigating to view page
public PageReference saverec() {
//this loop for updating bp response
for( Business_Plan_Response__c bprs: bp){
if(bprs.id!=null){
bpr.id=bprs.id;
bpr.Question_Txt__c=bprs.Question_Txt__c;
bpr.Response_Txt__c=bprs.Response_Txt__c;
update bpr;}
else{
bprs.Business_Plan_SFID__c=i;
insert bprs;
}
}
//this loop for updating bp proposal
for(Business_Plan_Proposal__c bpps:bprlst){
if(bpps.id!=null)
{
bpprop.id=bpps.id;
bpprop.Proposal_Txt__c=bpps.Proposal_Txt__c;
bpprop.Action_Txt__c=bpps.Action_Txt__c;
bpprop.Review_Txt__c=bpps.Review_Txt__c;
update bpprop;
}else{
bpps.Business_Plan_SFID__c=i;
insert bpps;
}
}
return null;
}
public PageReference cancel() {
return null;
}
}