I get the following error when I try to save a test class with List<sObject> recordTypes = Test.loadData(RecordType.sObjectType, 'Record_Types');

"Method does not exist or incorrect signature: void loadData(Schema.SObjectField, String) from the type System.Test"

If I replace RecordType with any other standard-object name (e.g. Account, Opportunity, CaseHistory, etc.), the code compiles. I tried googling the matter, but no luck.

Can a static resource of record types really not be loaded in apex, or am I missing something?

  • 1
    The fact that Record types are setup object data and we do not create them in apex tests as well. Hence it is not allowed with Load data.
    – Raul
    Jan 10 '18 at 14:54

Test.loadData would only work for non-setup data.

Also we do not create any record types from apex while testing. Best practice is to get record type Id's by describe calls.

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.