You need to sign in to do that
Don't have an account?
ckellie
Test Class Best Practice - 1 org or 1 per class/trigger?
I am in a project where i have to update all my test classes in my org with the new fields I am creating. A huge time commitment. What is best practice for apex code? Should I configure one class where I have create my test class records or create the test data in each test class? This affects 50+ test classes in my org.
This is recommended as it gives flexibity to modify your code and reusability of code so that if there are any changes to your app/objectsyou will have to do minimal modifications in you test codes.
Thanks,
N.J
Thank you
The idea is you would create a public class (you can also mark it with the isTest annotation so that it doesnt count against your code coverage). The public class would have public static methods called "loadData" or "loadAccounts" or whatever. These methods would simply insert your mock data. You could return the records too if you need to get their IDs or whatever.
In your test class, you would call it like so:
Another option you could use (I haven't gone this route myself) is using the load from CSV functionality. See this document for more information: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_load_data.htm
follow this: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_utility_classes.htm