I'm trying to write Unit Test which Involves doing an assertion on the formula field value.I know the formula field values will be calculated on fly.So I basically did an update on the record so that when I query for the record again I'd get the value.But even after the update when I try asserting the formula field the value being returned is NULL.
By the way I even queried the field.
Any thoughts on this.
Account acc = new Account(Name='Test Account',Company;='Test company');
Now I create a Contact for this Account .the contact has a formula field that takes the company value from Account.
Contact conRec = [Select Id,Company__c from Contact where AccountId=:acc.Id];
At this point I won't get any value so what I did is just an update on the contact like
....After this I queried for the same contact
c1 = [Select Id,Company__c from Contact where Ic=:conRec.Id]; System.assertEquals(c1.Company__c,acc.Company);
This fails because i get a null value