-
Notifications
You must be signed in to change notification settings - Fork 14
TestFactory
APIVERSION: 58
STATUS: ACTIVE
When we create a list of SObjects, we need to have a unique field for the insert if there isn't an autonumber field. Usually we use the Name field, but some objects don't have a name field.
Creates a single sObject.
| Param | Description |
|---|---|
sObj |
Type of sObject to create. |
| Type | Description |
|---|---|
| SObject | SObject |
Creates a single sObject
| Param | Description |
|---|---|
sObj |
Type of sObject to create |
doInsert |
Boolean should this object be inserted? |
| Type | Description |
|---|---|
| SObject | SObject |
creates a single sObject
| Param | Description |
|---|---|
sObj |
Type of sObject to create |
defaultClassName |
Name of the class to provide field defaults |
| Type | Description |
|---|---|
| SObject | SObject |
| Exception | Description |
|---|---|
TestFactoryException |
when defaultClassName param is not a valid type. |
Create a single sObject
| Param | Description |
|---|---|
sObj |
Type of sObject to create |
defaultClassName |
String name of a class providing default values |
doInsert |
Boolean should this method insert the created object? |
| Type | Description |
|---|---|
| SObject | SObject |
Creates a list of sObjects
| Param | Description |
|---|---|
sObj |
Type of sObjects to create |
numberOfObjects |
Integer number of objects to create |
| Type | Description |
|---|---|
| SObject | SObject[] |
Creates a list of sObjects
| Param | Description |
|---|---|
sObj |
Type of sObjects to create |
numberOfObjects |
Integer number of objects to create |
doInsert |
Boolean should this method insert the created object? |
| Type | Description |
|---|---|
| SObject | SObject[] |
public static List createSObjectList(SObject sObj, Integer numberOfObjects, String defaultClassName, Boolean doInsert)
SUPPRESSWARNINGS
Creates a list of sObjects
| Param | Description |
|---|---|
sObj |
Type of sObjects to create |
numberOfObjects |
Integer number of objects to create |
defaultClassName |
String name of a class providing defaults |
doInsert |
Boolean should this method insert the created object? |
| Type | Description |
|---|---|
| SObject | SObject[] |
public static List createSObjectList(SObject sObj, Integer numberOfObjects, String defaultClassName)
Creates a list of sObjects
| Param | Description |
|---|---|
sObj |
Type of sObjects to create |
numberOfObjects |
Integer number of objects to create |
defaultClassName |
String name of a class providing defaults |
| Type | Description |
|---|---|
| SObject | SObject[] |
Sets field defaults on the sObj given the map of defaults.
| Param | Description |
|---|---|
sObj |
Obj to manipulate. |
defaults |
Defaults map of sObjectField to Object to use for values. |
creates a test user. Useful for permissions testing
| Param | Description |
|---|---|
profileId |
Profile Id to use when creating a user. |
doInsert |
Boolean, should this code insert the user? |
| Type | Description |
|---|---|
| User | User |
Creates a test user with a given profile.
| Param | Description |
|---|---|
doInsert |
Should this code insert the created user? |
profileName |
Name of the profile to create the user with. |
| Type | Description |
|---|---|
| User | User |
Creates a user with the Minimum Access Profile Relies on the previous method for creating the user.
| Param | Description |
|---|---|
doInsert |
Should this code insert the user? |
| Type | Description |
|---|---|
| User | User |
Assigns a permission set to a given user.
| Param | Description |
|---|---|
user |
User to assign the permission set to. |
permSetName |
String name of the permission set. |
Intentionally invalidates a list of sObjects. This is useful for intentionally causing DML errors during testing.
| Param | Description |
|---|---|
incoming |
List of SObjects |
| Type | Description |
|---|---|
| List | List<sObject> |
Generates a marketing user - a user with the Marketing User profile.
| Param | Description |
|---|---|
doInsert |
Boolean True if you want this to insert your user. |
| Type | Description |
|---|---|
| User | User the created user |
Generates a test permission set record - no permissions are added to it
| Param | Description |
|---|---|
permSetName |
String what to call your perm set |
doInsert |
Boolean true if you want this to insert your perm set record. |
| Type | Description |
|---|---|
| PermissionSet | PermissionSet the created permission set. |
Enables a custom permission using a permission set
| Param | Description |
|---|---|
permissionName |
String name of the custom permission you want created |
forUserId |
Id user to assign the custom permission to. |
Internal custom exception class
Inheritance
TestFactoryException
Use the FieldDefaults interface to set up values you want to default in for all objects
Interface used by implementing classes to define defaults.
| Type | Description |
|---|---|
| Map<Schema.SObjectField,Object> | Map<Schema.SObjectField, Object> |