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
System Administrator 393System Administrator 393 

Using Formula Fields in Test Classes

I am writing a test class that tests for a class that checks the values of two formula fields and updates other fields. I am tryng to use thse fields in the test class, however, there values seem to be null. It does not seem like these formula fields are being updated. The genesis__Total_Score__c  and Annualized_Recurring_Revenue_Run_Rate__c field are the formula fields and their actual values are null, however all the required fields needed for their formulas have values. 

User-added image

Any help would be great. 

Thanksss
ApuroopApuroop
Hello,

Please post the code next time, rather than an image. :)

In your code, you need to query your record again after you have done your DML operatiions. Then do your asserts from that queried record. Like this:
//After all the insert and update statements...

genesis_Applications__c queriedApp = [SELECT Id, genesis__Total_Score__c, Annualized_Recurring_Revenue_Run_Rate__c FROM genesis_Applications__c WHERE Id =:app.Id] //Include all the fields that you want to check in this statement..

System.assertEquals(3000000, queriedApp.Annualized_Recurring_Revenue_Run_Rate__c);

//If you want to add more assert statements, just include those fields in the SOQL above..