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

Test Class for Below Trigger and @future method

Hi frnds I am New to write Test class plz help me out...........
My trigger ::::::::::::::::::::::::::::::::::;

trigger AddChatterGroup on User (after insert) {
               id userId =;


My Apex Class:::::::::::::::::::::
global class AsyncApex {
      public static void AddUserToGroup(id userId ) {
          try {
              List<CollaborationGroupMember> CG= new List<CollaborationGroupMember>();                     
              Id cgID = [ Select Id
                          FROM CollaborationGroup
                          WHERE Name ='Nnrgroup' LIMIT 1 ].ID;
             CG.add(new CollaborationGroupMember (CollaborationGroupId = cgID, MemberId = userId));  
             insert CG;
          } catch (QueryException qe) {
              System.debug('QueryException in AsyncApex.AddUserToGroup is :' + qe);
          } catch (Exception ex) {
              System.debug('Exception in AsyncApex.AddUserToGroup is :' + ex);
Gaurav NirwalGaurav Nirwal
Please tell me that the trigger can works and your requirements for write a trigger
yes it working right