You need to sign in to do that
Don't have an account?

Id not specified error in test class
I have a custom controller extension for a CampaignMember VF page that looks like:
public class landingSave { public CampaignMember cm; public landingSave(ApexPages.StandardController stdController) { this.cm = (CampaignMember)stdController.getRecord(); } public PageReference submit() { update cm; PageReference pageRef = new PageReference('http://www.someaddress.com'); return pageRef; } }
My test class currently looks like:
@isTest private class TestlandingSave{ static testMethod void mylandingSave() { PageReference pageRef = Page.Discover; Test.setCurrentPage(pageRef); Lead l = new Lead(lastname='smith'); Campaign c = new Campaign(Name='test campaign'); CampaignMember cm = new CampaignMember(lead=l, campaign=c, status='sent'); ApexPages.StandardController sc = new ApexPages.StandardController(cm); landingSave controller = new landingSave(sc); <!-- I THINK I'M MISSING SOMETHING HERE --> cm.XEmail__c = 'acme@gmail.com'; String nextPage = controller.submit().getUrl(); System.assertEquals('http://www.someaddress.com', nextPage); } }
Any pointers?! Thanks :smileyhappy:
I would think the Campaign and the CampaignMember must be inserted before the reference is passed to your controller extension.
So, it shoud read.
All Answers
I would think the Campaign and the CampaignMember must be inserted before the reference is passed to your controller extension.
So, it shoud read.
Doh!
Thanks for being my second set of eyes :-)