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
deeksharth srivastavadeeksharth srivastava 

how to write a test class for this

public with sharing class AddToCampaignController 
{
    public TTL_Residential__Property__c c{get;set;}
    private set<string> ids = new set<string>();
    public AddToCampaignController(ApexPages.StandardSetController standardController) 
    {
        for(Sobject standcont:standardController.getSelected())
        {
            ids.add(standcont.id);
          //  this.standardController = standardController;
        }
        c = new TTL_Residential__Property__c();
    }
    
    public void UpdateRecord()
    {
    
        list<TTL_Residential__Property__c> updtlst= new list<TTL_Residential__Property__c>();
        for(TTL_Residential__Property__c  obj2 :[select Id , Name,Campaign_Lookup__c from TTL_Residential__Property__c where id in:ids])
        {
            if(obj2.Campaign_Lookup__c ==null)
            {
            obj2.Campaign_Lookup__c=c.Campaign_Lookup__c;
            updtlst.add(obj2);     
            }            
        }
        if(updtlst.size()>0)
        update updtlst;
    }  
}
bob_buzzardbob_buzzard
Take a look at the introduction to apex testing page - that should get you started:

https://developer.salesforce.com/page/An_Introduction_to_Apex_Code_Test_Methods