1

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

1
  • 1
    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. Aug 13, 2015 at 11:48

1 Answer 1

2

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.

More information can be found here 1 2 3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .