You need to sign in to do that
Don't have an account?
tango
Test coverage for Apex class on VF page to display Campaign Members
I have a VF page to display the campaign members and i used an apex class to return a campaign Memeber List into a pageblocktable.
Everything works ok but i am having difficutly with creating the test coverage.
this gives an error with the class constructor..
Also curious if I can calculate the reg while generating the list view to be more efficient with the code.
Everything works ok but i am having difficutly with creating the test coverage.
Code:
public class CampMember { public final Campaign camp; public CampMember(ApexPages.StandardController controller) { this.camp = (Campaign)Controller.getRecord(); } public List<CampaignMember> getMemberList(){ List<CampaignMember> MemberList; if(MemberList == null) MemberList = [select ID,CampaignId,Contact.email, ContactId,Status,FirstRespondedDate,Contact.AccountId,Contact.VAR_Reseller_ID__c from CampaignMember where CampaignId = :camp.id ]; return MemberList; } public Integer getNumberReg(){ Integer NumberReg = 0 ; for(CampaignMember Reglist : [select ID,CampaignId,Contact.email, ContactId, Status from CampaignMember where CampaignId = :camp.id AND status = 'Registered' ]) { NumberReg++; } return NumberReg; } }
this gives an error with the class constructor..
Code:
static testMethod void testCampMemberpage() { PageReference pageRef = Page.CampMember; Test.setCurrentPageReference(pageRef); CampMember PageCon = new CampMember(); PageCon.getMemberList(); }
Also curious if I can calculate the reg while generating the list view to be more efficient with the code.
Please see the below post for more information:
http://salesforcesource.blogspot.com/2008/09/testing-your-controller-extentions.html
http://salesforcesource.blogspot.com/2008/09/testing-your-controller-extentions.html
question... Since we are using the test object as a part of the class construction do I still need to set the current page parameters (ID? )?
Code is working correctly with real data but the test asserts are failing expected values.