Activity Forums Salesforce® Discussions What are the best practices for test classes in Salesforce?

  • Anjali

    Member
    February 17, 2020 at 1:07 pm

    Best practice for Test Classes-

    • Never write a test class without starting it with ‘@isTest’.
    • For negative and positive, always put assert statements.
    • Avoid using hardcoded IDs.
    • It must have 75% coverage but always try to increase it to 95%.
    • Keep the real scenario in mind while writing a test class as it will handle any number of records.
    • Each branch of conditional logic must be tested.
    • This reply was modified 4 years, 1 month ago by  Forcetalks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos