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
Manisha GoparajuManisha Goparaju 

A developer wants multiple test classes to use the same set of test data.

Hi I am preparing for Saleforce Developer certification (PD-01) , I came acroos the below question.

A developer wants multiple test classes to use the same set of test data?

As per my kowledge , answer should be 'create set up method for each test class'

But in dump paper, it says,  "use seealldata==true annotaton in the test class"

i am not getting how it works, please explain.

Also please share dumps if u have
Best Answer chosen by Manisha Goparaju
sachinarorasfsachinarorasf
Hi Manisha,

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.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com

All Answers

sachinarorasfsachinarorasf
Hi Manisha,

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.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
www.sachinsf.com
This was selected as the best answer
Gokul DaghaleGokul Daghale
The correct  answer is creating Test Utility Class and referencing that in test class. Test utility classes are the one which are used for test Data creation and contain methods which are always public/global so that can be used by another test class.

for reference. - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_utility_classes.htm
Jaspreet Kaur 93Jaspreet Kaur 93
yes, above answer is right:

The correct  answer is creating Test Utility Class and referencing that in test class. Test utility classes are the one which are used for test Data creation and contain methods which are always public/global so that can be used by another test class.