function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Set Parameter Value to test the code


How can i set the parameter value in controller to Test my below code.

public with sharing class singleListView {
    public Campaign camp {get; set; }
    Public Lead lead{get;set;}
    List<CampaignMember>  CampaignMember = new List<CampaignMember>(); 
    public singleListView(ApexPages.StandardController controller) {
       camp = (Campaign)controller.getRecord();
    public List<Schema.Lead> CampaignMembers;
    public List<Schema.Lead> getCampaignMembers() {
   CampaignMembers=[Select Id,Name,(Select id, Campaign.Name,Contact.Phone,Lead.FirstName,Lead.LastName,LeadID,Lead.Phone,Lead.Email, Lastmodifieddate,Status,CampaignId,Campign_ID__c,Lead.MobilePhone  From CampaignMembers where CampaignId =:camp.Id and Status != '' and LeadId != null), 
(Select Subject, Id,lastModifiedDate From ActivityHistories  where lastModifiedDate !=null and Subject !=null order by LastModifiedDate desc limit 1) 
From Lead  where Name !=NULL and Id='00Q90000008fA5OEAU' order by LastModifiedDate desc];
       return CampaignMembers;
To do this you'll need to generate a standard controller for the object
public testmethod void myTest() {
     // Data to setup campaign object

     Campaign testCampaign = new Campaign();
     insert testCampaign;


     Apex.StandardController sc = new ApexPages.StandardController(testCampaign);
     singleListView controller = new singleListView(sc);

     // Rest of test


NOTE: This code has not been tested and may contain typographical or logical errors