Test methods should not create data instances directly as it puts tests at risk of breaking if new validation rules are added in the future. As a best practice, test data instances should be created in centralized test data factories, so that the introduction of new validation rules don't break existing test methods.
This rule detects circumstances where instances of data objects are created directly, introducing the problem.


  • Apex test methods

  • SObject definitions

Did this answer your question?