Skip to main content
1 of 3
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

You have to create the records. See also:

#Isolation of Test Data from Organization Data in Unit Tests

Starting with Apex code saved using Salesforce API version 24.0 and later, test methods don’t have access by default to pre-existing data in the organization, such as standard objects, custom objects, and custom settings data, and can only access data that they create. However, objects that are used to manage your organization or metadata objects can still be accessed in your tests such as:

  • User
  • Profile
  • Organization
  • AsyncApexJob
  • CronTrigger
  • RecordType
  • ApexClass
  • ApexTrigger
  • ApexComponent
  • ApexPage

You can create an org default setting in a variety of ways. One such:

MySetting__c defaults = MySetting__c.getOrgDefaults();
defaults.SomeField__c = 'Some Value';
upsert defaults;
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431