You need to sign in to do that
Don't have an account?
Test Class Help for VF Page
I have a VF page that we created that looks like this:
<apex:page standardController="Lead" extensions="TeamTrackFlag" sidebar="true">
<apex:sectionHeader title="Edit Lead Record:"
subtitle="{!lead.name}"/>
<apex:form >
<apex:pageBlock title="Create TeamTrack Flag" id="thePageBlock"
mode="edit">
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<FONT COLOR="RED"><b>IMPORTANT: </b> Should a TeamTrack be created for this Opportunity?</FONT>
<br /><br />
<table>
<td width="200" align="center"><b>Create TeamTrack?</b></td>
<td width="100" align="left"><apex:inputField value="{!Lead.Create_TeamTrack__c}" id="TTFlag"/></td>
<td width="200" align="left"> Checked = YES<br />Unchecked = NO<br /></td>
</table>
<br />
<br />
<B>PLEASE NOTE:</B>
<BR />
The system default is 'YES'. Your answer should only be 'NO' if you were notified by Recruitment Support about a TeamTrack that was manually created on your behalf.
<apex:inputField value="{!Lead.ID}" rendered="false" />
<apex:inputField value="{!Lead.Name}" rendered="false" />
<apex:inputField value="{!Lead.Company}" rendered="false" />
</apex:pageBlock>
</apex:form>
</apex:page>
The class is:
public class TeamTrackFlag{
ApexPages.StandardController controller;
Lead cntr;
public TeamTrackFlag(ApexPages.StandardController con){
controller = con;
cntr= (Lead)controller.getRecord();
}
public PageReference save()
{ controller.save();
PageReference redirecturl = new PageReference('/lead/leadconvert.jsp?retURL=/' + cntr.Id + '&id=' + cntr.Id + '&noopptt=' + cntr.Company + '-' + cntr.Name);
redirecturl.setRedirect(true);
return redirecturl;
}}
I do I get test coverage for this page so that we can deploy it production from our sandbox?
Check this for writing test class
http://forceschool.blogspot.com/2011/06/testing-apex-structure-of-test-class.html
Writing a test class for standard controller which is your case is not covered in the link provided by Shashikant. Here are some good links :
http://salesforcesource.blogspot.com/2008/09/testing-your-controller-extentions.html
Covering all cases in test class :
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_example.htm
Another very good link :
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
@ankit
Thanks for reading my blog but my friend you missed that i also provided standard controoler case in example
I hope you can see it now.
To be more specific if newbie's are asking for test classes then just a simple text won't help them much I guess.
If you are writing a blog over test classes then it would be helpful for all if you provide some test samples and code to get broad view.
Hope you got my point this time.
First of all newbie's is only status for community not for his understanding level . I think we all are newbie and learning thing here. Yes it might be not be possible that it is not helpful for him , it might be possible links that you provided are also not helpful, but I think whether they are or not can only be decided by them only not by us. And you cahnged your stance first you said I did not provide standard controlle in example , now when I showed you lines those give instructions for them you are saying not much help , whats your intension Mate :)