I know @isTest annotation is used to mark test classes and by default does not include the data in the org. However, I have noticed that it still includes some of the metadata/configuration of the org (e.g., users, profiles, roles, scheduled jobs, etc.). I am not using SeeAllData=true. Where can I find an exhaustive list of things (or defining criteria) for what is included and what is excluded in test classes marked with @isTest?
1 Answer
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
Read the document and understand it as there are all sorts of considerations within the doc
Google search is awesome
-
1