salesforce dynamic test data factory

By October 21, 2016Latest News

1239116_smjpg_9g401782yc272012eThe worst part about writing salesforce apex code?  Writing those unit tests and test classes!

We’ve decided we’ve had enough.  We present to you the Dynamic Test Data Factory!

What is it? We’ve created an Apex class that will read the metadata of any salesforce org and create test data for an object with all required fields populated. Just specify the object, number of records and let the Data Factory do the rest! It will even set any unique text/number fields that are required without any repeats. We also have the ability to pass in specific values of fields that must be populated to test whatever scenario your class needs to be written for.

How is it done?  See the code snippet below:





In this sample, we are creating test data for an Account object with a custom field of a date.

By calling the createRecords method, we are creating 200 records of sample data on the account object.  That should be enough to get us up to 100% code coverage.

That’s it!

Not only is it cool, but it will save you a TON of time in having to write test classes.

Are you looking to spend more time developing and less time writing test classes in Apex?  We thought so.  Fill out to form below to discuss with us how you can leverage the Dynamic Data Test Factory!