You need to sign in to do that
Don't have an account?
how to test the code...or write test class?
i have written a code for the show this functionality..
There is an custom button on contact record page...on the click of this button an vf page will open which will show 5 fields of this contact and 5 fields of the account associated with this contact..
i have written this code..please help me writing test class for this code..
public class contactdetail
{
public Contact con{get;set;}
public string retid{get;set;}
public PageReference pr;
public List<Contact> contactrecord{get;set;}
public List<Account> cppz;
public List<Contact> oppz;
public contactdetail(ApexPages.StandardController controller)
{
retid=ApexPages.currentPage().getParameters().get('id');
this.con=(Contact)controller.getRecord();
pr=new PageReference('/'+retid);
pr.setRedirect(true);
}
Public PageReference Contactdetails()
{
return pr;
}
public List<Contact> getOppz()
{
Contact con1= [Select id FROM Contact where id = :con.id];
if (con1.id == null)
return null;
oppz = [Select c.FirstName, c.Fax, c.Email, c.Department, c.Birthdate, c.AssistantName From Contact c where c.Id = :con1.id];
return oppz;
}
public List<Account> getCppz()
{
Contact con2= [Select id ,AccountId FROM Contact where id = :con.id];
if (con2 .AccountId == null)
return null;
cppz = [Select a.Type, a.Phone, a.Name, a.CreatedDate, a.Birthday__c From Account a where a.Id = :con2.AccountId ];
return cppz;
}
}
Hi
these links will help
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
http://boards.developerforce.com/t5/Apex-Code-Development/Need-help-creating-an-Apex-Test-Class/td-p/249507
http://forceschool.blogspot.in/2011/06/testing-apex-structure-of-test-class.html
http://forceschool.blogspot.in/2011/06/testing-trigger-structure.html
http://www.forcetree.com/2011/06/guide-to-writing-test-methods-for-apex.html
if you are unable write please let me know
i read these.please help how do i call my class methods in class and insert records into test class.