Using the Test.loadData method, you can populate data in your test methods without having to write many lines of code.
Follow these steps:
Add the data in a .csv file.
Create a static resource for this file.
Call Test.loadData within your test method and passing it the sObject type token and the static resource name.
For example, for Account records and a static resource name of myResource, make the following call: List<sObject> ls = Test.loadData(Account.sObjectType, 'myResource');
Using the Test.loadData method, you can populate data in your test methods without having to write many lines of code.
Follow these steps:
Add the data in a .csv file.
Create a static resource for this file.
Call Test.loadData within your test method and passing it the sObject type token and the static resource name.
For example, for Account records and a static resource name of myResource, make the following call: List<sObject> ls = Test.loadData(Account.sObjectType, 'myResource');
ANS: Static Resources.
Loading Test Data :
Using the Test.loadData method, you can populate data in your test methods without having to write many lines of code.
Follow these steps:
- Add the data in a .csv file.
- Create a static resource for this file.
- Call Test.loadData within your test method and passing it the sObject type token and the static resource name.
For example, for Account records and a static resource name of myResource, make the following call:List<sObject> ls = Test.loadData(Account.sObjectType, 'myResource');
More info : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_load_data.htm
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: salesforcestart1@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Thanks,
V Varaprasad
Email: salesforcestart1@gmail.com
All Answers
Correct answer is (A) Static Resources.
Thank You,
www.nubeselite.com
Development | Training | Consulting
Please mark this as solution if your problem is solved.
ANS: Static Resources.
Loading Test Data :
Using the Test.loadData method, you can populate data in your test methods without having to write many lines of code.
Follow these steps:
- Add the data in a .csv file.
- Create a static resource for this file.
- Call Test.loadData within your test method and passing it the sObject type token and the static resource name.
For example, for Account records and a static resource name of myResource, make the following call:List<sObject> ls = Test.loadData(Account.sObjectType, 'myResource');
More info : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_load_data.htm
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Salesforce Freelance Consultant/Developer/Administrator/Trainer
@For Salesforce Project Support: salesforcestart1@gmail.com
Salesforce latest interview questions and training videos :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Thanks,
V Varaprasad
Email: salesforcestart1@gmail.com