You need to sign in to do that
Don't have an account?
Som_11
What is the best practice to write test classes where we need to add product
What is the best practice to write test classes where we need to add product for OrderItem. Should we create an New product as part of test data as we are creating account.
Yes you need to craete the products in test class. Sample code is below:
Let me know if you need more help
Thanks,
Abhishek Bansla.
Hi Somesh,
Except a few setup objects, no data is available in test classes by default.
So as a thumb rule, you MUST create test data for all objects that you need for your logic to run.
It's well explained here - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_data.htm
Hope this helps.
Best,
Vishal