Please help me how to cover the red highlighted block below.
I am getting the 70% coverage in the test class. The constructor block is not getting covered. Can you please help me.
public class CLS_AccountEditPage { public String Account { get; set; } Public String CompanyType{get;set;} Public String AccountName{get;set;} Public String Industry{get;set;} Public String AccountSiteCity{get;set;} Public String Phone{get;set;} Public String Website{get;set;} Public String ParentAccount{get;set;} Public String AccountSiteLocation{get;set;} public Account acc{get;set;} public string surl = ''; public id aid{get;set;}
PageReference pageRef = new PageReference('/Apex/VF_AccounteditPage?id=001XYZEDG');
Your Page Reference does not have '001' in the URL per your IF Statement. When you do your page reference you are just giving it the VF page wihtout any parameters which whoulc include the 001 string.
Also, FYI you can bind directly to SObjects in your VF Page. So instead of having 10 lines of code where you set CompanyType, AccountName, etc. YOu could just bind directly to acc.Name like this:
<Apex:inputField value = {!acc.CompanyType}>
and in your controller you wouldn't need to do these line:
PageReference pageRef = new PageReference('/Apex/VF_AccounteditPage?id=001XYZEDG');
Your Page Reference does not have '001' in the URL per your IF Statement. When you do your page reference you are just giving it the VF page wihtout any parameters which whoulc include the 001 string.
Also, FYI you can bind directly to SObjects in your VF Page. So instead of having 10 lines of code where you set CompanyType, AccountName, etc. YOu could just bind directly to acc.Name like this:
<Apex:inputField value = {!acc.CompanyType}>
and in your controller you wouldn't need to do these line:
In your test method try something like this:
PageReference pageRef = new PageReference('/Apex/VF_AccounteditPage?id=001XYZEDG');
Your Page Reference does not have '001' in the URL per your IF Statement. When you do your page reference you are just giving it the VF page wihtout any parameters which whoulc include the 001 string.
Also, FYI you can bind directly to SObjects in your VF Page. So instead of having 10 lines of code where you set CompanyType, AccountName, etc. YOu could just bind directly to acc.Name like this:
<Apex:inputField value = {!acc.CompanyType}>
and in your controller you wouldn't need to do these line:
AccountName=acc.name;
Industry=acc.Industry;
phone=acc.phone;
Website=acc.Website;
CompanyType=acc.Company_Type__c;
AccountSiteCity=acc.Account_Site_City__c;
AccountSiteLocation=acc.Account_Site_Location__c;
All Answers
In your test method try something like this:
PageReference pageRef = new PageReference('/Apex/VF_AccounteditPage?id=001XYZEDG');
Your Page Reference does not have '001' in the URL per your IF Statement. When you do your page reference you are just giving it the VF page wihtout any parameters which whoulc include the 001 string.
Also, FYI you can bind directly to SObjects in your VF Page. So instead of having 10 lines of code where you set CompanyType, AccountName, etc. YOu could just bind directly to acc.Name like this:
<Apex:inputField value = {!acc.CompanyType}>
and in your controller you wouldn't need to do these line:
AccountName=acc.name;
Industry=acc.Industry;
phone=acc.phone;
Website=acc.Website;
CompanyType=acc.Company_Type__c;
AccountSiteCity=acc.Account_Site_City__c;
AccountSiteLocation=acc.Account_Site_Location__c;
Hello Cory Cowgill,
Thanks a lot. Worked out the the logic
Thanks,
Uday