I am not able to find an answer to why the Test Data Factory class begins with @isTest. Does anyone here have a clue ?
Thanks
I am not able to find an answer to why the Test Data Factory class begins with @isTest. Does anyone here have a clue ?
Thanks
Because with @isTest this class code don't count in your overall code limit also you make change in the database in the Test Data Factory class if this is a test class then it don't affect your actual database. Also you don't need to cover this class and this class can be called from Actual test class which is helpful that no one can accidentally change your data. As stated in docs
The TestDataFactory class is a special type of class—it is a public class that is annotated with isTest and can be accessed only from a running test. Test utility classes contain methods that can be called by test methods to perform useful tasks, such as setting up test data. Test utility classes are excluded from the org’s code size limit.