Activity Forums Salesforce® Discussions What is the use of @IsTest(SeeAllData=true) Annotation in Salesforce?

  • Nikita

    Member
    August 12, 2019 at 1:20 pm

    Hi Prachi,

    You can use the @isTest(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization. The access includes pre-existing data that the test didn’t create.

    If a test class is defined with the @isTest(SeeAllData=true) annotation, the annotation applies to all its test methods. The annotation applies if the test methods are defined with the @isTest annotation or with the (deprecated) testMethod keyword.

    The @isTest(SeeAllData=true) annotation is used to open up data access when applied at the class or method level. However, if the containing class has been annotated with @isTest(SeeAllData=true), annotating a method with @isTest(SeeAllData=false) is ignored for that method. In this case, that method still has access to all the data in the organization. Annotating a method with @isTest(SeeAllData=true) overrides, for that method, an @isTest(SeeAllData=false) annotation on the class.
    @isTest(SeeAllData=true) and @isTest(isParallel=true) annotations cannot be used together on the same Apex method.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos