You need to sign in to do that
Don't have an account?
petergascoyne
Test Data Objects
Hi people,
The problem I have is, I have an application I have been working on and to test it I need a large amount of Custom Objects, over 100.
What would be the best way to create 100 test Custom Objects?
Would I be able to quickly add and remove these at anytime?
Thanks
Peter
Please review the Force.com Apex Code Developers Guide (http://www.salesforce.com/us/developer/docs/apexcode/index.htm) , speciifcally the section 'Testing Apex'
1. Any records you create in a method marked 'testMethod' will be not be commited to the DB after the test is run. You can just think of it as automatically deleting all your test records.
2. Inside your testMEthod, to create a large amount ot test objects you can do soething like this:
List<Custom__c> customList = new List<Custom__c>():
for(Integer x = 0; x < 100; x++)
{
Custom__c customObj = new Custom__c();
customObj.Name = 'UnitTestName' + x;
customList.add(customObj);
}
insert customList;
you are talking about the records or objects ?
I am talking about the actual Custom Object not a record of the object.
I think there is a solution maybe using the metadata API.
Thanks
Yes then you can create the objec via metadeta api.