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
Ramesh SomalagariRamesh Somalagari 

How to write a test case for Chatter Feed Post

Hi,

I have trigger which fires when a Post is inserted in the Chatter.
How do I write a test case for that.
My Trigger code is

rigger ChatterFeedPost on FeedItem (After Insert) {
  
List <Control_data__c> controldata = new List<Control_data__c>();
list<Messaging.SingleEmailMessage> maillist = new list<Messaging.SingleEmailMessage>();
List <TopicAssignment> topassg = new List<TopicAssignment>();
List <Topic> topicname = new List<Topic>();
controldata = [Select id,Name,Data__c,Reference__c from Control_data__c where name = :'CHT'];
TRY
{
     For(FeedItem item : Trigger.New)
     {
       
            if(controldata.size()!=0)
            {
              
                   topassg = [Select id,topicid,entityid from topicassignment where entityid = :item.id];              
                   For(Topicassignment newtop:topassg)
                   {
                       topicname = [Select name from topic where id = :newtop.topicid];
                       if(topicname.size()!=0)
                       {
                           for(Topic finname: topicname)
                           {
                               For(Control_data__c cdata:controldata)
                               {
                                   /* Do something */
                               }
                             
                           }                     
                       }
                                  
                   }
                 
              
            }
              
          
    }
}
CATCH(Exception e){
    System.debug('MAIN EXCEPTION'+e);
}

}

Now how do I write a test case for this Trigger.
Please help me out ...
Vinita_SFDCVinita_SFDC
Hello,

Please refer following chatter workbook for sample test class code for feeds:

http://www.salesforce.com/us/developer/docs/workbook_chatter/chatter.pdf