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
m 3m 3 

Can you please help me this apex class and testclass with using system assert equals

    class
public B_AsyncContactImport_Mailchimp(String mailChimpListId, Integer members_count, Integer members_offset, Boolean insertDuplicates, Integer saved_members_count, String tagName) {
        this.mailChimpListId = mailChimpListId;
        this.members_count = members_count;
        this.members_offset = members_offset;
        this.insertDuplicates = insertDuplicates;
        this.saved_members_count = saved_members_count; //initially it's zero.
        this.tagName = tagName;
    }
     test class
    @isTest 
    static void test_AsyncContactImport_Mailchimp(){

        Test.startTest(); 
        String listMembersResponse = '{"members":[{"id":"a89d6fa724ea206edb06cd262ce6bf1d","email_address":"user+11@test.com","unique_email_id":"8984312e5e","email_type":"html","status":"subscribed","merge_fields":{"FNAME":"FirstOne","LNAME":"LastOne"},"list_id":"5abcf1f4c5"}],"list_id":"5abcf1f4c5","total_items":1}';
        Test.setMock(HttpCalloutMock.class, new B_HttpCalloutMock(200, 'OK', listMembersResponse, null));
        try {
                B_AsyncContactImport_Mailchimp obj = new B_AsyncContactImport_Mailchimp('5abcf1f4c5',2,3,true,3,'tagName');
                //obj.execute(null);
                System.enqueueJob(obj);
             (new B_AsyncContactImport_Mailchimp('1005',2,3,false,3,null)).execute(null);
            } catch(Exception e) {
                //System.debug('!=== Exception: ' + e.getStackTraceString());
                System.assert(e.getMessage() != null);
            }
        Test.stopTest() ;           
    }
TruptiTrupti
What you want here??
Raj VakatiRaj Vakati
try this
 
@isTest 
    static void test_AsyncContactImport_Mailchimp(){

        Test.startTest(); 
        String listMembersResponse = '{"members":[{"id":"a89d6fa724ea206edb06cd262ce6bf1d","email_address":"user+11@test.com","unique_email_id":"8984312e5e","email_type":"html","status":"subscribed","merge_fields":{"FNAME":"FirstOne","LNAME":"LastOne"},"list_id":"5abcf1f4c5"}],"list_id":"5abcf1f4c5","total_items":1}';
        Test.setMock(HttpCalloutMock.class, new B_HttpCalloutMock(200, 'OK', listMembersResponse, null));
        try {
                B_AsyncContactImport_Mailchimp obj = new B_AsyncContactImport_Mailchimp('5abcf1f4c5',2,3,true,3,'tagName');
                //obj.execute(null);
                System.enqueueJob(obj);
            
            } catch(Exception e) {
                
                System.assert(e.getMessage() != null);
            }
        Test.stopTest() ;   

System.assertEquals('5abcf1f4c5',obj.mailChimpListId );
System.assertEquals(true,obj.insertDuplicates  );
System.assertEquals(3,obj.saved_members_count  );

        
    }