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
renaiah anamalla 7renaiah anamalla 7 

Why we are using Seealldata=true in test cases,

Why we are using Seealldata=true in test cases,

Why we are using Private in test cases.
Rohit Sharma 66Rohit Sharma 66
In test classes if we want to query data from the sfdc database then We use seeAllData = true, however it is not recommended to query data from SFDC database, because let say if you query some data from sandbox and ur test classes passed. Now when u move ur code to production then ur test classmight fail because u won't get any data based on ur query in test classes. So its always recommended to create test data in test classes.
Following links u can refer:

Let me know if it helps.
Class is defined using the @isTest annotation can only contain test methods. One advantage of creating a separate class for testing, it don't count against your organization limit of 3 MB for all Apex code.

In test class and methods, we can access data in the organization. Prior to it we can just access test data. Using this we can access organization data. For Apex code saved using API version 24.0 and later, use the isTest(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.
Starting with Apex code saved using API version 24.0, test methods don’t have access by default to pre-existing data in the organization. However, test code saved against API version 23.0 or earlier continues to have access to all data in the organization and its data access is unchanged.

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.