A Salesforce CLI Plugin to simplify synthetic data generation for Salesforce.
Smock-It is a fast, lightweight SF CLI plugin that simplifies Salesforce test data generation, overcoming the limitations of standard Salesforce and third-party tools. With its ability to create synthetic, highly customizable datasets, it`s perfect for anyone working with complex Salesforce schemas.
Whether you`re a developer, QA engineer, or admin, Smock-It adapts to your unique testing requirements, ensuring efficiency, compliance, and scalability. With its ability to generate accurate, diverse test data in less time, you can focus on what truly matters—building, testing, and delivering great solutions.
Smock-It v2.1.0 brings smarter, faster test data generation for Salesforce, with:
Take full control of your test data with enhanced template creation. Now, include or exclude specific fields (fieldsToConsider, fieldsToExclude) or control data behavior using pickLeftFields, for precise scenario-specific results.
No more hassle with environment variables! Use the new -a flag to authenticate with a username or alias from your Salesforce Org List, simplifying setup for the validate and data generate commands.
Say goodbye to the 1,000-record cap! Now, you can generate significantly larger datasets across CSV, JSON, and DI formats, making it easier to handle large-scale test data requirements with zero restrictions.
No more missing fields! Smock-It now automatically detects and includes required fields, ensuring that every dataset is complete, compliant, and ready for testing—without manual intervention.
Dependent picklist and picklist value check: Smock-It now verifies that predefined values exist in the org. If no predefined value matches in the org, Smock-It will not generate any data.
Required Fields Fix for Data Generation: Smock-It now automatically handles required fields to ensure smooth and accurate test data generation.
Relationship Handling up to Two Levels: With Smock-It users can
- Handle parent-child relationships.
- Handle child-parent-grandparent relationships, with the grandparent field being mandatory.
Smock-It removes the biggest roadblocks Salesforce professionals face when managing and generating test data.
Stop worrying about using real customer data. Smock-It creates synthetic, privacy-safe test data, keeping you fully compliant with GDPR and CCPA while protecting both your business and customers.
Manually generating complex Salesforce test data is resource-intensive and a slow grind. Smock-It automates the process, significantly cutting down the time and effort required to generate accurate test data.
Salesforce custom objects and relationships can make test data creation tricky. Smock-It understands and processes complex schemas, ensuring your test data is always structured and accurate.
Smock-It lets you complete control over your test data with features like:
- fieldsToConsider – Choose specific fields to include at the object level for precise, scenario-specific test data.
- fieldsToExclude – Remove unnecessary fields for cleaner, more focused datasets.
- pickLeftFields – Set to true to generate all fields except the excluded ones, or false to generate only the selected ones.
Before installing Smock-It, ensure you have the following:
- Salesforce CLI – Required for executing Smock-It commands within your Salesforce environment. Install it from here.
- Node.js (v18.0.0 or later) – Smock-It requires Node.js to run. Download the latest version from Node.js.
- Mockaroo API Key – Smock-It integrates with Mockaroo for generating realistic test data. Obtain your API key from Mockaroo.
Run the following command in your terminal to install Smock-It as a Salesforce CLI plugin:
sf plugins install smock-it
Keep Smock-It up to date with the latest enhancements by running:
sf plugins update
To confirm that Smock-It was installed successfully, run the below command. This will list all installed plugins, including Smock-It.
sf plugins
Smock-It relies on Mockaroo to generate realistic, structured test data. To enable this integration, you need to set up a Mockaroo API key as an environment variable.
$env:MOCKAROO_API_KEY="your_mockaroo_api_key"
export MOCKAROO_API_KEY="your_mockaroo_api_key"
📌 Note: You can obtain your Mockaroo API key by signing up at Mockaroo.
When using Smock-It, the following directories are automatically created in your current working directory (if they don’t already exist). These directories help organize your test data, making it easier to manage and reuse:
-
data_gen/
– The root directory where all Smock-It generated test data is stored. It acts as the primary workspace for data generation.-
templates/
– Contains data templates that define field structures, relationships, and constraints, ensuring test data aligns with Salesforce schema requirements. -
output/
– The output directory stores generated test data files and record insertion details, making it easy to track or reuse datasets later.
-
The sf template init
command generates a data template based on the values provided in the questionnaire.
Please refer INIT_QUESTIONNAIRE_GUIDE.MD for more detail.
{
"templateFileName": "default_data_template.json",
"namespaceToExclude": [],
"outputFormat": ["csv"],
"language": "en",
"count": 1,
"sObjects": [
{ "account": {} },
{ "contact": {} },
{
"lead": {
"language": "en",
"count": 5,
"fieldsToExclude": ["fax", "website"],
"fieldsToConsider": {
"country": ["India", "USA"],
"dp-year__c": ["2024"],
"dp-month__c": ["March"],
"email": []
},
"pickLeftFields": true
}
}
]
}
For more on Template Use Cases, Please refer - USECASE.md
-
Fax & Website: These fields are excluded from data generation, meaning no values will be created for them.
-
Country: Data will be generated only for India and the USA. No other country values will be included.
-
Email: Since no specific values are provided, random email addresses will be automatically generated.
-
dp-Year__c: This serves as a controlling field (parent) for a dependent picklist. It will always have a fixed value of 2024 during data generation.
-
dp-Month__c: A dependent field linked to
dp-Year__c
. It will always generate the value "March", with no variations. -
Dependent Picklists: The order of dependent picklists is important. The controlling field (
dp-Year__c
) must be listed before the dependent field (dp-Month__c
) in the template. -
Field Prefix: Fields that are part of a dependent picklist must begin with the prefix
dp-
. -
dp-
Fields: Fields with thedp-
prefix must either be left empty or have a single predefined value. Multiple values are not supported.
This command initializes a new data generation template. It sets up the required directory structure, prompts for a valid template file name, and collects configuration details for Salesforce objects (such as fields to exclude and record counts). Once all necessary inputs are gathered, the configuration undergoes validation against the org before being saved to a JSON file.
sf template init [--default]
The Upsert command allows users to modify or add configurations to an existing data generation template. Users can specify details such as Salesforce object, language, record count, excluded fields, and output format. If the specified object does not already exist in the template, the command will prompt users to add it.
sf template upsert -t <templateFileName> [-s <sObject>] [-l <languageCode>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>] [-i <fieldsToConsider>] [-p <pickLeftFields>]
Remove specific configurations from an existing data generation template using the remove command. Users can remove record count, language, namespaces, output format, and excluded fields.
Note: While these options offer flexibility, record count and language cannot be removed globally, and at least one output format must remain to ensure proper functionality
sf template remove -t <templateFileName> [-s <sObject>] [-l <languageCode>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>] [-i <fieldsToConsider>] [-p <pickLeftFields>]
The validate command validates a data generation template file, ensuring that it is correctly configured for Salesforce. It checks the template for correctness, connects to Salesforce (using environment variables for credentials), and logs any warnings or errors found in the template's configuration. This step ensures that all objects, fields, and settings are properly defined before use.
Note: To execute this command, the user will need to mention the alias name or username of the Salesforce Org.
sf template validate -t <templateFileName> -a <aliasorUsername>
The generate command reads a Salesforce data generation template and generates data based on the objects and settings defined within it. It also excludes the fields from the data template file that have been specified, ensuring that unwanted fields are omitted from the generated records. This command is designed to facilitate the creation of tailored datasets for Salesforce objects.
Note: To execute this command, the user will need to mention the alias name or username of the Salesforce Org.
sf data generate -t <templateFileName> -a <aliasorUsername>
The print command retrieves and displays the contents of a specified Salesforce data generation template. It is useful for reviewing the configuration before using it to generate data.
sf template print -t <templateFileName>
Flag | Short Hand | Flag Name | Description |
---|---|---|---|
--default |
Default Template | Creates a default template. | |
--templateName |
-t |
Template Name | Specify the name of the data template to be utilized. The template must exist in the data_gen/templates directory. |
--count |
-c |
Count | Set the number of records to generate. If --sObject or -s is provided, this will only update or remove the count for that object. |
--namespaceToExclude |
-x |
Namespace to Exclude | Exclude specific namespaces from generating record data for namespace fields. Multiple namespaces can be separated by commas. |
--language |
-l |
Language | Select the language (en ). When --sObject or -s is specified, this updates or removes the language setting for that object. |
--outputFormat |
-f |
Output Format | Define the output format(s) for generated data (e.g., CSV, JSON, DI). Multiple formats can be specified, separated by commas. |
--sObject |
-s |
Specific Object | Target a specific object and override its existing settings. If not found in the template, an "add object" prompt will appear. |
--fieldsToExclude |
-e |
Fields to Exclude | Exclude specific fields from test data generation for a given object. Applies only at the object level. |
--fieldsToConsider |
-i |
Fields to Consider | Include specific fields from test data generation for a given object. This applies only at the object level, with the specified values |
--pickLeftFields |
-p |
Pick Left Fields | If true, generates data for all fields except those listed in FieldsToExclude. If false, generates data only for the fields specified in FieldsToConsider. |
--aliasOrUserName |
-a |
Alias Or UserName | This flag is required when using the validate and data generate commands. It accepts a username or alias name and only supports orgs listed in the Salesforce Org List. |
To access command help:
sf <template/data> <command> --help