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
AnwarAnwar 

How to write Formula field in Test class

Hi All,

 

How to write  Formula field in Test class

 

 

Thanks

Anwar

@anilbathula@@anilbathula@

Hi Anwar,

 

I think ur not able to cover the formula field in the test class.

its not need to write the formula field in the test class.

Just While inserting data in the test class.

please insert the field which give the out put of formula.

Ex:-field a+field b= field c(Formula field).

Ur test method will be like this :-

object o=new object(o.filed a=10,o.field b=20);

insert o;

It automatically covers the formula.

 

Thanks

Anil.B

 

SFFSFF

If, however, you want to validate that the formula is calculating correctly as part of your test class - which is a very good idea if not something that we usually do - all you have to do is update the values of the fields that make up the formula, and then use system.assertEquals to validate that the formula returns the correct value.

 

Good luck!

AnwarAnwar

Hi All,

 

Thanks For Replay

 

Thanks

Anwar

Vishnu SanthoshVishnu Santhosh
Thanks @anilbathula@