You need to sign in to do that
Don't have an account?
Testing code
I have the following code that I am trying to write a test method for and am not able to figure out how to make this work.
public class MyExtension
{
public Work_Order__c wo{get; set;}
opportunity opp;
public MyExtension(ApexPages.StandardController controller)
{
opp=[select id,accountId from opportunity where id=:controller.getId()];
wo = new Work_Order__c();
wo.Opportunity__c=opp.id;
if(opp.AccountId!=null)
wo.Account__c=opp.AccountId;
}
public PageReference save()
{
insert wo;
PageReference woPage = new ApexPages.StandardController(wo).view();
woPage.setRedirect(true);
return woPage;
}
public PageReference cancel()
{
PageReference woPage = new ApexPages.StandardController(wo).view();
woPage.setRedirect(true);
return woPage;
}
}
This code runs a visualforce page that creates a record for a custom object relating back to the opportunity and the opportunity account. Custom object is called a work order. Let me know if there is anything I can do to test this.
here is a start for you:
Modify as necessary and add your systemAsserts as needed to verify the correct things are happening