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
Anurag PareekAnurag Pareek 

Urgent Help about seeAllData=true

HI Folks, 

What purpose we  can use seeAllData=true,in realtime.. Like what is the basic approach of using this ? I want to  know the realtime  functionality behind this.

Thanks 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
http://amitsalesforce.blogspot.in/2015/09/test-classes-with-istest.html
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000D9guIAC

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

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

 
REVNAREVNA

SeeAlldata = true , is nothing but referring to the org data as opposed to creating test data in test class. 
Is it best practice to do it ? - No
Is it ok to do it ? Yes . But your test class may fail when deploying to other org , because the data in the destination org may not comply 
Can we avoid doing it ? Yes . Create test data in your test class
Then why do we need this ? Salesforce has some objects for which we cannot create test data , in which case you need to use org data , to cover your code.