Smock-it is a powerful CLI plugin for generating mock data for Salesforce testing. It simplifies the creation of compliant, relationship-aware test data, allowing developers, QA teams, and admins to quickly generate and use unique datasets directly within their Salesforce orgs.
Want to get started with Smock-it? Quick Start Guide.
Smock-it v3 brings smarter, faster test data generation for Salesforce, with:
The latest version 3.0.3 makes generating data much easier, as the tool can now generate data directly from natural language using the sf smockit promptify command. Simply describe your data requirements in plain English, and Promptify will generate a valid Smock-it JSON template and generate the data for you, eliminating the need for manual steps. From template creation to data generation, everything will be done on the fly.
Smock-it introduced the excludeSObjects flag (-z) from v3.0.2, allowing you to skip specific SObjects from data generation — even if they're defined in your saved template. This is helpful when you have a large template with multiple objects but want to generate data for only a few at a time, without modifying the original template.
Now you can generate data for specific record types using the new --recordType
(-r
) flag. This is especially useful when an object like Account has multiple record types but you only want to include a few relevant fields tied to a particular type. Define the record type directly in your data generation command.
Note: Only users with the
System Administrator
profile are allowed to generate data for specific record types.
From v3.0.2, Smock-it addded greater flexibility to how data is distributed across fields. Suppose you're generating 20 records for an object like Opportunity — you can now apply conditional logic to split records across specific field values. For example, generate 15 records where StageName
is set to Closed Won and another 5 where it's Closed Lost. This level of control can be applied directly at the object level within your template.
Smock-it has removed its dependency on Mockaroo and now includes its own data library (v0.0.3), enabling the generation of 100% unique data — up to 300K records — while complying with Salesforce standard duplicate rules.
When generating location-based data, Smock-it intelligently associates countries with their respective states and cities, ensuring the data is both logical and realistic.
Using advanced, context-aware algorithms, it generates realistic names, industries, emails, currencies, and other text-based data. This ensures that your test data closely mirrors real-world scenarios, enhancing its authenticity and reliability.
The new data upload feature allows users to upload generated datasets to different orgs using the username or alias. This makes it seamless for teams to test across environments with the exact same dataset.
Smock-it removes the biggest roadblocks Salesforce professionals face when managing and generating test data.
Smock-It lets you easily upload and reuse generated data across different orgs, making it seamless for teams to test with the same dataset. This ensures consistency and accuracy across environments.
QAs need test data that looks realistic, and Smock-It delivers just that. The data it generates isn’t just random numbers or text; it’s context-aware, logically correct, and closely resembles real-world scenarios. This ensures that the data is not only realistic but also meaningful.
With no API dependencies, data generation time has drastically reduced, from approximately 15 minutes for 200,000 records to just 2 minutes. It also removes previous limitations, allowing unlimited data generation per day.
Before installing Smock-it, ensure you have the following:
- Salesforce CLI
- Node.js (v18.0.0 or later)
Run the following command in your terminal to install Smock-it as a Salesforce CLI plugin:
sf plugins install smock-it
To confirm that Smock-it was installed successfully, run the below command. This will list all installed plugins, including Smock-it.
sf plugins
Keep Smock-it up to date with the latest enhancements by running:
sf plugins update
When running template init command, the following directories are automatically created in your current working directory (if they don’t already exist). These directories help to organize your output test data and template configurations, making it easier to manage and reuse:
PROJECT_BASE/
├── data_gen/
│ ├── templates/ #refer to template structure
│ │ ├ createAccount.json
│ ├── output/ #refer to Output
│ │ ├ CreateAccount_DI_Ouput.json
│ │ ├ CreateAccount_CSV_Ouput.csv
│ │ ├ CreateAccount_JSON_Ouput.json
While creating the template through template init, you will be prompted with questions to fully customize your template based on your test data needs. Alternatively, this can now also be done using the promptify command, where you simply provide your requirements in natural language, and after a few quick checks, a template will be generated automatically.
For a complete guide on template creation using template init
, please refer to Template Init Questionnaire.
For template creation using promptify, visit the Promptify Guide.
Below is an example template:
{
"namespaceToExclude": ["testGen"],
"outputFormat": [
"di",
"csv",
"json"
],
"count": 200,
"sObjects": [
{
"account": {
"count": 50,
"fieldsToExclude": ["fax"],
"fieldsToConsider": {
"name": [],
"email": [],
"dp-country__c": ["USA"],
"dp-state__c": ["California"]
},
"pickLeftFields": true
}
}
]
}
For more on Template Use Cases, Please refer Common Template Use Cases.
Smock-it generates output based on the format provided in the template configuration file. Currently it supports csv, json and DI format where DI means Direct Insert into your Salesforce org.
📌 Important Migration Notice
Allsf template
andsf data
commands are being deprecated in favor of the newsf smockit
namespace.
See the Legacy Command Migration section below for a complete mapping.
Create fresh template for data generation. Read more
sf smockit template init [--default]
Generate template and data using natural language. Read more
sf smockit promptify
Note: This command combines both template creation and data generation into a single step—no need to run multiple commands. Based on your requirements, you can choose to generate data immediately by answering “yes,” or save the template for future use.
Check data generation template for correctness. Read more
sf smockit template validate -t <templateFileName> -a <aliasorUsername>
Generate and/or insert data based on the objects and settings defined within the template. Read more
sf smockit data generate -t <templateFileName> -a <aliasorUsername>
Note: The alias name or username of the Salesforce Org is required.
Upload generated data (JSON) to multiple orgs. Read more
sf smockit data upload -u <filename.json|filename.csv> -a <alias_or_username> -s <sObject>
Note: Make sure to append the filename with .json to upload the data.
Review the template configuration before using it to generate data in read-only. Read more
sf smockit template print -t <templateFileName>
Modify or add configuration to an existing template. Read more
sf smockit template upsert -t <templateFileName> [-s <sObject>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>] [-i <fieldsToConsider>] [-p <pickLeftFields>]
Remove specific configurations from an existing data generation template. Read more
sf smockit template remove -t <templateFileName> [-s <sObject>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>] [-i <fieldsToConsider>] [-p <pickLeftFields>]
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. |
--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. |
--upload |
-u |
Upload | The -u command is used to upload the generated JSON data into the target Salesforce org. |
--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. |
--excludeSObjects |
-z |
ExcludesObjects | This flag skips a specific SObject during data generation, even if it's included in the template file. |
--recordType |
-r |
recordType | Generate data for a specific Record Type for specified object by passing its name with the -r flag. |
⚠️ Deprecated Commands
The following commands are deprecated and will be removed in a future version. Please update your scripts to use the newsf smockit
commands.
Legacy Command | New Command |
---|---|
sf template init |
sf smockit template init |
sf template validate |
sf smockit template validate |
sf template generate |
sf smockit data generate |
sf data upload |
sf smockit data upload |
sf template print |
sf smockit template print |
sf template upsert |
sf smockit template upsert |
sf template remove |
sf smockit template remove |
Integrate Smock-it within the DevOps pipeline. Read more
To access command help:
sf <template/data> <command> --help