Skip to main content Take our 5-minute Community Survey. Open now through 4/11/2025. Click here to participate.

https://trailhead.salesforce.com/pt-BR/content/learn/modules/asynchronous_apex/async_apex_future_methods?trail_id=force_com_dev_intermediate on this trailhead i keep getting this error, stopping me from getting the badge, does anybody knows what it is ? 

here is my code: 

public without sharing class AccountProcessor {

@future

    public static void countContacts(List<id> accountIds){

        List<Account> accounts = [SELECT Id,(SELECT Id FROM Contacts) FROM Account WHERE Id IN :accountIds];  

        

        for (Account acc: accounts) {

            acc.Number_Of_Contacts__c = acc.Contacts.size();

        }

        

        update accounts;

    }

}

test method: 

@isTest

private class AccountProcessorTest {

    

    @isTest 

    private static void countContactsTest(){

        

        List<Account> accounts = new List<Account>();

        for(Integer i=0; i<300; i++){

            accounts.add(new Account(Name='Test Account' + i));

        }

        insert accounts;

        

        List<Contact> contacts = new List<Contact>();

        List<Id> accountIds = new List<Id>();

        for (Account acc: accounts) {

            Contacts.add(new Contact(FirstName=acc.name, LastName='TestContact', AccountId=acc.Id));

            accountIds.add(acc.Id);

        }

        

        insert contacts;

        

        Test.startTest();

        AccountProcessor.countContacts(accountIds);

        Test.stopTest();

        

    }

}

1 answer
0/9000