You need to sign in to do that
Don't have an account?
PS81
Test class for standard controller
Hello
I have a standard controller overriding the 'edit page' for opportunity. Need some help to write a test class to do a code coverage for this standard contlr please?
my overridding page :
and the class :
I have a standard controller overriding the 'edit page' for opportunity. Need some help to write a test class to do a code coverage for this standard contlr please?
my overridding page :
<apex:page standardController="Opportunity" tabStyle="Opportunity" extensions="OpportunitySave" > <apex:sectionHeader title="Opportunity Edit" subtitle="{!Opportunity.name}"/> …. …. …. <body> <apex:pageBlock title="Opportunity Edit" mode="edit" > <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save" /> <apex:commandButton action="{!Cancel}" value="Cancel"/> </apex:pageBlockButtons> <apex:pageblocksection id="OprInfo" title="Opportunity Information" columns="2"> <apex:inputfield value="{!Opportunity.name}" id="oprname"/> <apex:inputfield value="{!Opportunity.AccountId}" id="opraccname" required="true"/> …. …. ….
and the class :
public with sharing class OpportunitySave { public string probs {set;get;} public boolean disable{set;get;} public Opportunity opr {get;set;} private ApexPages.StandardController stdCtrl; public OpportunitySave(ApexPages.StandardController controller) { stdCtrl = controller; opr = (Opportunity)controller.getRecord(); disable = false; } public PageReference setpresales(){ if (opr.Type == 'Big Ticket') opr.Presales__c = 'Yes'; else opr.Presales__c = 'No'; return null; } public PageReference setProbability(){ } return null; }
Try with belwo code and add mandatory fields to the test record .
For reference and concepts of test class please follow belwo link .
http://manojjena20.blogspot.in/2015/06/tips-and-tricks-for-test-class.html
Let me know if it helps !!