You need to sign in to do that
Don't have an account?
Chitral Chadda
vf page test class
i hav custon button "create deal" , which on click calls this action.
Name__c is a (look up fields to account) on test 1 object
<apex:page standardController="Test_1__c" extensions="CreateDeal" >
<script type="text/javascript">
window.onload = function () {
//document.frmLead.sendButton.click();
dealInJS();
}
</script>
<apex:form >
<apex:pageMessages escape="false" />
<apex:outputPanel layout="block" style="font-weight:bold;text-align:center">
Converting Deal. Please wait...
</apex:outputPanel>
<apex:actionFunction action="{!deal}" name="dealInJS" >
</apex:actionFunction>
</apex:form>
</apex:page>
public class CreateDeal
{
private id accountId{get;set;}
public Test_1__c b{get;set;}
public CreateDeal(ApexPages.StandardController controller)
{
accountId= ApexPages.currentPage().getParameters().get('id');
system.debug('+++'+accountId);
}
public pageReference deal()
{
Test_1__c b = [Select id,Name__c,Name11__c,Number__c,Phone__c from Test_1__c where id =:accountId];
Test_2__c a = new Test_2__c();
{
a.Name11__c=b.Name11__c;
a.Number__c=b.Number__c;
a.Phone__c=b.Phone__c;
a.Name__c=b.Name__c;
}
insert a;
PageReference pageRef = new PageReference('/'+a.id);
pageRef.setRedirect(true);
return pageRef;
}
}
how to write test class for this, i read few documentation but i cant prepare the test class
Name__c is a (look up fields to account) on test 1 object
<apex:page standardController="Test_1__c" extensions="CreateDeal" >
<script type="text/javascript">
window.onload = function () {
//document.frmLead.sendButton.click();
dealInJS();
}
</script>
<apex:form >
<apex:pageMessages escape="false" />
<apex:outputPanel layout="block" style="font-weight:bold;text-align:center">
Converting Deal. Please wait...
</apex:outputPanel>
<apex:actionFunction action="{!deal}" name="dealInJS" >
</apex:actionFunction>
</apex:form>
</apex:page>
public class CreateDeal
{
private id accountId{get;set;}
public Test_1__c b{get;set;}
public CreateDeal(ApexPages.StandardController controller)
{
accountId= ApexPages.currentPage().getParameters().get('id');
system.debug('+++'+accountId);
}
public pageReference deal()
{
Test_1__c b = [Select id,Name__c,Name11__c,Number__c,Phone__c from Test_1__c where id =:accountId];
Test_2__c a = new Test_2__c();
{
a.Name11__c=b.Name11__c;
a.Number__c=b.Number__c;
a.Phone__c=b.Phone__c;
a.Name__c=b.Name__c;
}
insert a;
PageReference pageRef = new PageReference('/'+a.id);
pageRef.setRedirect(true);
return pageRef;
}
}
how to write test class for this, i read few documentation but i cant prepare the test class
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_error_handling.htm