You need to sign in to do that
Don't have an account?
Michael Sypro
Test method issues
Hello All,
I've been having trouble trying to write a test method for this class... I'm not sure if it's because I'm using querystring parameters or what, but any help would be appreciated.
public with sharing class msaOppExtension { public String locToSet {get;set;} public String statusToSet {get;set;} public Opportunity o; public msaOppExtension(ApexPages.StandardController ctr) { o = [SELECT MSA_Location__c, MSA_Location_Date__c, MSA_Returned__c, MSA_PO__c, MSA_Deposit__c FROM Opportunity WHERE Id=:ctr.getRecord().Id]; } public PageReference updateLoc() { o.MSA_Location__c = locToSet; o.MSA_Location_Date__c=System.Now(); string f = ApexPages.currentPage().getParameters().get('from'); if (f =='Releases' && locToSet=='Releases'){ o.MSA_Returned__c=true; } else { o.MSA_Returned__c=false; } update o; return null; } public PageReference updateStatus() { o.MSA_Status__c = statusToSet; update o; return null; } public PageReference updateCancel() { o.MSA_Location__c = 'Archive'; o.MSA_Location_Date__c=System.Now(); o.StageName='Closed Lost'; o.Reason__c='Duplicate'; o.Lost_To_Competitor__c='Other'; update o; return null; } public PageReference createNew(){ string oppId=ApexPages.currentPage().getParameters().get('id'); o.MSA_Location__c = 'Processing'; o.MSA_Location_Date__c=System.Now(); o.MSA_PO__c='Not Started'; o.MSA_Deposit__c='Not Started'; update o; List<MSA__c> rows = new List<MSA__c>(); rows.add(new MSA__c(Opportunity__c=oppId, RecordTypeId='01270000000UJ4M'));//Invoice insert rows; String newPageUrl = '/apex/MSA_Processing?l=Processing&ddl=VA'; PageReference newPage = new PageReference(newPageUrl); newPage.setRedirect(true); return newPage; } } }
If you have parameters that are set in the constructor it is useful to use the following before instantiating your controller in the test method:
For the actual construction you would first create the Object, then the Standard controller, and finally your custom controller:
Then perform your tests.
Hi
Could u post ur test class plz.
Regards,
Rajesh.