You need to sign in to do that
Don't have an account?
hylim1215
please help my test method on custom extension
Hi i have a custom exten for my Quote object as below:
Thanks.
public with sharing class quote_NewQuoteExtension{ ApexPages.StandardController controller; public Opportunity opp2 {get; set;} public Account acc {get; set;} public Contact ctc {get; set;} private Quote qo; public quote_NewQuoteExtension(ApexPages.StandardController stdController){ controller = stdController; qo = (Quote)stdController.getRecord(); oid = System.currentpageReference().getParameters().get('oppid'); if(opp2 == null){ opp2 = [Select id, Pricebook2Id,name, accountid, Type_of_Quote__c, Contact_Name__c from opportunity where id =: oid]; } . .. }and my test method always show list has no row on opp2 list. my test unit
public static testMethod void MainTestClass(){ account acc = new account(name='xx' ..); insert acc; contact ctc = new contact(name = 'xx'..); insert ctc; opportunity opp = new opportunity(name = 'xx'..); insert opp; quote qo = new quote(name='xx'); insert qo; ApexPages.StandardController sc = new ApexPages.StandardController(quo); quote_NewQuoteExtension testNewQuoteExt = new quote_NewQuoteExtension(sc); PageReference pageRef = Page.quote_NewQuoteMaster; Test.setCurrentPage(pageRef); testNewQuoteExt.opp2 = opp; testNewQuoteExt.acc = acc; testNewQuoteExt.ctc = ctc; testNewQuoteExt.save(); }i have already set opp2 why still null?
Thanks.
Add this line to ur test class,
ApexPages.currentPage().getParameters().put('oppid',opp.Id);
Thanks,
Nagendra
i tried but it sill return error "list has no row returned". Any idea?
Thanks