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
Amita TatarAmita Tatar 

how do i cover following test class ..please help

Hi Guys,

I have below test class and i am not able to cover the part after OLI id field as it is coming blank.
Its a formula field haveing as formula in it. 

User-added image

Amita Tatar
This is something I have faced before, I learned that the formula fields are NOT SO DYNAMIC in test execution, at least not the way you think they are... I was under the impression that they get calculated when you want to read them, I was wrong, the formula fields get evaluated the moment the data is saved, and the references will also apply those changes. 

Here is the trick, you can try:

1 - Make a DML on that test data in test class, so the formula gets evaluated during test run and then query of that particular field and try
2 - In the trigger: instead of using the formula in your code, query for the referencial field, like q.quote.opportunityid.
3 - Worst of all, move it from formula to a text field and populate that using text