You need to sign in to do that
Don't have an account?
Justin Duross
Using Future Methods Trailhead Help
Hello, for the Salesforce Trailhead "Using Future Methods" I keep getting the error "The 'AccountProcessorTest' test class doesn't appear to be calling the 'AccountProcessor.countContacts' method between Test.startTest() and Test.stopTest()." I believe I have the right syntax, so I'm not sure what is wrong. My main class is fine. the problem only seems to be in the AccountProcessorTest.apxc
AccountProcessorTest.apxc
Here is my main class in case anyone needs it:
AccountProcessor.apxc
Thank you in advance!
Justin Duross
AccountProcessorTest.apxc
@isTest private class AccountProcessorTest { @isTest static void countContacts() { Test.setMock(AccountProcessorTest.class, new Account()); Test.startTest(); AccountProcessor.countContacts(); Test.stopTest(); } }
Here is my main class in case anyone needs it:
AccountProcessor.apxc
global class AccountProcessor { @future public static void countContacts(Set<id> setId){ List<Account> lstAccount = [SELECT Id, Number_of_Contacts__c, (SELECT Id FROM Contacts) FROM Account where id in : setid]; for(Account acc: lstAccount){ List<Contact> lstCont=acc.contacts; acc.Number_of_Contacts__c = lstCont.size(); } update lstAccount; } }
Thank you in advance!
Justin Duross
1) https://developer.salesforce.com/forums/?id=906F0000000D8hwIAC
Please update your Test class like below:- Let us know if this will help you
All Answers
1) https://developer.salesforce.com/forums/?id=906F0000000D8hwIAC
Please update your Test class like below:- Let us know if this will help you
Please give me a clarification, Can we write code for this callenge like below (as Account 'a' is already available in the same method) Instead of like this (as you did) Thanks in advance,
Javeed