How does one generate real world type data and populate Salesforce test instances with this data that may be needed for testing? Does Salesforce provide any services to generate/provide this type of data if one's own production org does not have it currently? I am assuming that I have created/purchased a new sandbox and it needs to be populated.

Thanks, Giri


Quite often I just end up cannibalizing code snippets from my unit tests ;)

The more effort you'll put into making unit tests that don't rely on existing data and attempt to test in bulk loads (200+ Accounts for example), the less trouble you have later when you need to "prime" a blank sandbox.

In the end you know your data best. If you can extract meaningful slices from production (and load them to sandbox keeping referential integrity... External Id fields are good for that) - awesome. If not - there will be only so much you can squeeze from dummy data generators and the chance is you already have some well-written unit tests.

If the size of data needed is huge and you won't be able to load it all in 1 transaction you could even end up having a class that you'd use only in sandboxes (it'd never be deployed to production). Split the created data into several methods, call each in separate transaction and you're done.

|improve this answer|||||

Salesforce does not provide a way to generate test data; that is left up to the users. There are many tools on the market that can examine schemas and automatically generate data.

In addition, you may want to look at Copy Production data to Developer Sandbox for data loading techniques.

|improve this answer|||||

One great option for creating data to populate your sandbox or Dev Org for general testing is to go to a site called GenerateData.com, specify the field names you want, the type of data the field contains, the field's format, number of records, etc., and it will generate random data for you which you can use to import into your org to use for testing.

The site lets you select the format you want the data saved in for download. You can have the data output as either HTML, Excel, XML, CSV or SQL. Up to 200 records can be downloaded at a time for free. If you donate $20 or more, you get an account that lets you download up to 5000 records at a time with your settings saved for up to a year. This is one of the most useful sites I've found if you're looking for to generate random test data of this type.

Obviously, you can use DataLoader or another appropriate utility to import the data into your org once you've downloaded it.

I should add that there's also a GNU licensed version you can download that allows you to create as much data you desire provided you have a web server available to set it up to run from.

|improve this answer|||||

There is a free app on the AppExchange that will automatically create test accounts, contacts, leads, and opportunities when installed. The test data will even be deleted if you uninstall the app. Pretty slick stuff:


|improve this answer|||||
  • While neat, I doubt it will work in any org that is even slightly customized. I could be wrong though cause I have not tried it... – Eric Mar 8 '17 at 3:17
  • I imagine customizations could be a limitation in some cases. It does detect required fields and populates them with a simple test value, but custom validation rules might cause issues. The app is mostly meant for new orgs that still need configuring anyhow. – Brent Thomas Mar 9 '17 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.