4

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
  • 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
    Commented Jan 10, 2018 at 14:54

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .