• Justin Duross
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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
@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

 
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
@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

 
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
@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