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 '15 at 11:48
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.