Skip to main content

Posts

Showing posts from November, 2018

Experiment : Test.loadData . Upload test data with static resources

Test.loadData  is a method that enables us to create test data by using Static Resource. This was released quite sometimes but I haven't use it intensively. I experienced using it to load data in bulk because I wanted to test governor limit. Recently we plan to use this on our project instead of using test data factory.Pushing test data using csv files are much easier compare to code insertion and define relationship. I did some simple proof of concept using code below : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 @isTest private class DataUtil { static testmethod void testLoadData () { // Load the test accounts from the static resource List<sObject> ls = Test. loadData (Account. sObjectType , 'AccountData'); // Verify that all 3 test accounts were created System. assert (ls. size () == 3 ); // Get first test account