@isTest
static void testIncrement() {
Account acct = new Account(Name = 'Test');
acct.Number_Of_Times_Viewed__c = 0;
insert acct;
AuditUtil.incrementViewed(acct.Id);
Account acctAfter = [SELECT Number_Of_Times_Viewed__c FROM Account WHERE Id = :acct.Id][0]
System.assertEquals(1, acctAfter.Number_Of_Times_Viewed__c);
}
The test method above calls an @future method that increments the Number_of_Times_Viewed__c value. The assertion is failing because the
Number_of_Times_Viewed__c equals 0.
What is the optimal way to fix this?
Soliton321
Highly Voted 3 years, 10 months agosinghkar
Highly Voted 3 years, 5 months agoJokei
Most Recent 11 months, 3 weeks agoVVeguru
1 year, 4 months agosanto_aj
1 year, 6 months agosf2022
1 year, 12 months agoChiaSam
2 years, 5 months agodrwebber
2 years, 11 months agoamerbearat
3 years, 3 months ago