function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Karna_ShivaKarna_Shiva 

Difference between seeallData=true seeAllData =false

When we can use and shouldn't use seeallData=true

what are adventages and disadventages of seeallData=true and seeallData=false?
Best Answer chosen by Karna_Shiva
Amit Chaudhary 8Amit Chaudhary 8


IsTest(SeeAllData=true) Annotation
use the isTest(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization,
1) If a test class is defined with the isTest(SeeAllData=true) annotation, this annotation applies to all its test methods whether the test methods are defined with the @isTest annotation or the testmethod keyword
2) The isTest(SeeAllData=true) annotation is used to open up data access when applied at the class or method level

http://amitsalesforce.blogspot.in/2015/09/test-classes-with-istest.html

Use the isTest(SeeAllData=true) means you need to create the test data in your org.

User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent ,ApexPage we can access without (seeAllData=true) .
SeeAllData=true will not work for API 23 version eailer .

NOTE:- Always try to avoid use SeeAllData= true because in that case your test class depend on  your sandbox data. You May get some issue will deployment.

Let us know if this will help you



 

All Answers

Sunil MadanaSunil Madana
Please refer to the below URL for more information.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_isTest.htm
geeta garggeeta garg
Hi Karna,
 seeallData=true or seealldata=false is used in test class.
 IsTest(SeeAllData=true) is used to  open up data access to records in your organization.some time it can create the problem.
 IsTest(SeeAllData=false) is not used to  open up data access to records in your organization and you need to insert the record.

Thanks,
Geeta Garg

 
Vijay NagarathinamVijay Nagarathinam
HI,

SeeAlldata=true is mainly used when testing code written in Salesforce : 
(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization, including pre-existing data that the test didn’t create.

This way you can run SOQl inside test class and work on that data to test the trigger or class u've created.

If set to false - user should then create his own data form the test class and work on it to test the written code.

Thanks,
Vijay
Amit Chaudhary 8Amit Chaudhary 8


IsTest(SeeAllData=true) Annotation
use the isTest(SeeAllData=true) annotation to grant test classes and individual test methods access to all data in the organization,
1) If a test class is defined with the isTest(SeeAllData=true) annotation, this annotation applies to all its test methods whether the test methods are defined with the @isTest annotation or the testmethod keyword
2) The isTest(SeeAllData=true) annotation is used to open up data access when applied at the class or method level

http://amitsalesforce.blogspot.in/2015/09/test-classes-with-istest.html

Use the isTest(SeeAllData=true) means you need to create the test data in your org.

User, profile, organization, AsyncApexjob, Corntrigger, RecordType, ApexClass, ApexComponent ,ApexPage we can access without (seeAllData=true) .
SeeAllData=true will not work for API 23 version eailer .

NOTE:- Always try to avoid use SeeAllData= true because in that case your test class depend on  your sandbox data. You May get some issue will deployment.

Let us know if this will help you



 
This was selected as the best answer
Karna_ShivaKarna_Shiva
isTest(SeeAllData=true) - is there any draw back with this anntation?
Amit Chaudhary 8Amit Chaudhary 8
Yes .Always try to avoid use SeeAllData= true because in that case your test class depend on  your sandbox data. You May get some issue will deployment
Karna_ShivaKarna_Shiva
NOTE:- Always try to avoid use SeeAllData= true because in that case your test class depend on  your sandbox data. You May get some issue will deployment.

this is the point i am looking, 

Thanks all:)