Activity Forums Salesforce® Discussions Is there any difference between the @isTest and @testSetup notation in Salesforce test class?

  • Yogesh

    August 12, 2019 at 2:37 pm


    Use the @isTest annotation to define classes and methods that only contain code used for testing your application.

    One Test class can have Multiple @isTest methods


    Methods defined with the @testSetup annotation are used for creating common test records that are available for all test methods in the class.

    One Test class can have only one @testSetup methods

  • Deepak

    August 12, 2019 at 2:38 pm

    Method marked with @TestSetUp annotation executes before any testMethod.
    Data created in this method doesn’t need to be created again and again, and it is by default available for all test methods.
    There can be only one setup method per test class.
    Test setup methods are supported only with the default data isolation mode for a test class. If the test class or a test method has access to organization data by using the @isTest(SeeAllData=true)annotation, test setup methods aren’t supported in this class

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos