Smock-it GitHub Actions: Instant Salesforce Mock Data for CI/CD!

Why Smock-it GitHub Action for Salesforce Mock Data? 🤔

Reliable Salesforce testing demands consistent, structured, and scalable mock data. Manual methods often fail due to:

Challenges with Manual Salesforce Mock Data in CI:CD.png
  • Missing test records, causing inconsistent test results.

  • Unavailable test data cause frequent CI/CD pipeline disruptions.

  • Repeated manual data setups across sandboxes or scratch orgs.

  • Data conflicts in collaborative developer teams.

  • Difficulty managing complex Salesforce relationships (Accounts, Opportunities, Cases).

  • Compliance risks associated with using real customer data.

Smock-it’s GitHub Action addresses these pain points by automating test data generation directly within your Salesforce CI/CD workflows.

Benefits of Smock-it in Salesforce CI/CD

  • ⚙️ Fully Automated: Trigger test data generation directly from GitHub Actions.

  • 🔄 CI/CD Friendly: Seamlessly integrates with GitHub Actions for automatic data generation before test execution

  • 🌐 Universal Org Compatibility: Works with scratch orgs, sandboxes, UAT, and staging.

  • 📈 Customizable & Scalable: Templates tailor data to your precise business requirements.

  • 👩‍💻 Rapid Developer Onboarding: Instantly provision configured environments for new team members.

  • 🔐 Compliance Assured: Synthetic test data eliminates privacy concerns, adhering strictly to GDPR and similar regulations.

Comparison: Smock-it vs. Manual Salesforce Mock Data Creation 🔍

Feature Manual Creation ❌ Smock-it GitHub Action ✅
🚀 Speed Slow (hours of effort) Instant (minutes)
⚡️ Consistency Variable per environment Fully consistent & repeatable
📌 CI/CD Integration Not integrated Easy integration into GitHub Actions
👥 Team Collaboration Frequent data conflicts Standardized & reusable datasets
📊 Structured Data Difficult to maintain Easily supports complex models
🔒 Compliance Risky – possible exposure of PII Secure synthetic data generation

Complete Setup Guide for Smock-it GitHub Action 🛠

Prerequisites:

Repository Structure:

  • Rulesets (template files) are present for data generation.

  • Store templates: data_gen/templates/

  • Generated data outputs: data_gen/output/

Integration Steps

#1 With Existing WorkFlow

  • Ensure you have all prerequisites in your existing GitHub Workflow and Repository.

  • Add a new secret to your repository, MOCKAROO_API_KEYand pass the generated API Key on as a value.

    • Navigate to your repository on GitHub.

    • Go to "Settings" > "Secrets and variables" > "Actions" > "Secrets".

    • Click "New repository secret".

    • Enter a name for your secret i.e. MOCKAROO_API_KEY

    • Paste the API key or sensitive value into the "Value" field.

    • Click "Add secret".

  • Pass other required parameters(templates, org-alias) per your workflow configurations.

  • Add the below step to your existing workflow after all prerequisite steps.

- name: generate data using smock-it
     uses: concretios/smock-it@main
     with:
       templates: ${{ inputs.templates }}
       org-alias: ${{ inputs.org-alias }}
       mockaroo-api-key: ${{ secrets.MOCKAROO_API_KEY }}
  • Step Parameters:

  • templates: In case of a different Event than workflow_dispatch, one can hardcode the template names in string.

    • e.g. accountCreate.json, leadCreate.json, closedWonOpp.json, etc.

  • org-alias: You can extract the value of alias from the previous step(org authorization) and add it here; otherwise, you can always have a static hardcoded value of alias, which should be the same as you passed in the previous step.

  • You can also add a new step(if it does not exist already) to upload the artifacts of data_gen/output/ directory to get the generated output of smock-it data.

- name: upload artifacts
  uses: actions/upload-artifact@v4
  with: 
    name: SmockItOutputFiles
    path: data_gen/output/
    retention-days: 15 #(max. 90 days)
    if-no-files-found: warn #(warn, error, ignore)

#2 With New WorkFlows

  • Follow all the prerequisites.

  • Add the below workflow to your repository.

name: Smock-it - Salesforce Test Data Generation

on:
  workflow_dispatch:
    inputs:
      templates:
        description: "Provide comma-separated templates name (e.g lead_creation.json, account_creation.json)"
        required: true
        type: string
      org-alias:
        description: "Provide alias for authorizing salesforce org"
        required: true
        type: string
        default: "smockit"

jobs:
  generate-test-data:
    runs-on: ubuntu-latest # You can add choice of your runner
    steps:
    - name: checkout repository
      uses: actions/checkout@v4
    - name: setup node
      uses: actions/setup-node@v4
      with:
        node-version: 18
    - name: install Salesforce CLI
      run: |
        npm install -g @salesforce/cli
        echo "SF CLI Installed."
    - name: create server-key file from stored secrets
      run: |
        echo "${{ secrets.JWT_TOKEN }}" > server.key 
    - name: connect your org using jwt
      run: |
        sf org login jwt --client-id ${{ secrets.CLIENT_ID }} --jwt-key-file server.key --username ${{ secrets.username }} -r instance_url --alias ${{ inputs.org-alias }}
    - name: generate data using smock-it
      uses: concretios/smock-it@main
      with:
        templates: ${{ inputs.templates }}
        org-alias: ${{ inputs.org-alias }}
        mockaroo-api-key: ${{ secrets.MOCKAROO_API_KEY }}
    - name: upload artifacts
      uses: actions/upload-artifact@v4
      with: 
        name: SmockItOutputFiles
        path: data_gen/output/
        retention-days: 15
        if-no-files-found: warn 


#📌 Important Notes
#🔹 You must have a `data_gen` directory** in your repository with:
#   - data_gen/templates/ → Stores Smock-it template files.
#   - data_gen/output/ → Stores the generated test data.

#🔹 Ensure GitHub Secrets are configured correctly:
#   - JWT_TOKEN → Your Salesforce private key.
#   - CLIENT_ID → Salesforce connected app client ID.
#   - username → Salesforce user email.
#   - MOCKAROO_API_KEY → API key for realistic test data generation.
# JWT Authentication link: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_auth_jwt_flow.htm

Smock-it Github Actions Workflow Breakdown

 
🛠 Expected Smock-it Github Workflow Execution.png
 

1️⃣ Workflow Trigger: `workflow_dispatch`: This workflow is manually triggered using `workflow_dispatch`. It requires two user inputs:

templates – Comma-separated list of template files (e.g., `lead_creation.json, account_creation.json`).
org-alias – Alias for the Salesforce org authorization (defaults to `smockit`).

2️⃣ Define Job: `generate-test-data`: Defines the job named generate-test-data and runs it on ubuntu-latest.

3️⃣ Check out the Repository: Uses actions/checkout@v4 to fetch the latest repository code and ensures required folders are available.

4️⃣ Set Up Node.js: Sets up Node.js v18, which is required for running Smock-it and Salesforce CLI.

5️⃣ Install Salesforce CLI: Installs Salesforce CLI (sf command) globally to interact with Salesforce from the command line.

6️⃣ Create the Server Key File from Secrets: Retrieves the JWT private key from GitHub Secrets (JWT_TOKEN) and stores it as server.key.

7️⃣ Authenticate Salesforce Org Using JWT: Uses Salesforce CLI to authenticate the org using JWT authentication with the given credentials.

8️⃣ Generate Test Data Using Smock-it: Calls `concretios/smock-it@main` to generate test data based on the provided templates.

9️⃣ Upload Generated Data as an Artifact: Uploads generated test data (`data_gen/output/`) as an artifact named `SmockItOutputFiles` with a retention period of 15 days.

Real-World Use Cases for Smock-it GitHub Actions

 
Real-World Use Cases for Smock-it GitHub Actions.png


 

1️⃣ Scratch Org Setup with Preloaded Data: Create a Salesforce scratch org and automatically populate it with test data. This enables developers to instantly start testing without manually setting up records.

2️⃣ CI/CD Pipeline Integration: Ensure every CI/CD pipeline execution has the necessary test data for integration and UI tests. No more failing tests due to missing records or incorrect data.

3️⃣ Automated UAT Data Generation: Prepare user acceptance testing (UAT) environments with consistent, structured data: preload customer accounts, orders, and related records to simulate real-world workflows.

4️⃣ Regression Testing with Clean Data: Run regression tests with fresh, predictable datasets. Helps identify bugs and performance issues without inconsistencies in test environments.

5️⃣ Sandbox Refresh with Required Data: After refreshing a sandbox, instantly reload essential test data. There is no need to re-enter customer records, orders, or custom objects manually.

6️⃣ Performance and Load Testing: Generate large-scale data sets to simulate production-like load in Salesforce. Analyze system performance under stress conditions with structured mock data.

7️⃣ Data Masking for Compliance: Generate test data that mimics production without exposing sensitive customer information. Ensure GDPR and data protection compliance while running tests.

8️⃣ Custom Business Process Testing: Simulate end-to-end business processes (e.g., lead conversion, case resolution) with preloaded related data to validate real-world scenarios.

9️⃣ Multi-Environment Support: Use Smock-it in dev, test, UAT, and production staging environments to ensure data consistency across teams.

FAQs

Q1: Can I use Smock-it in multiple CI/CD environments?
A: Yes. Smock-it supports scratch orgs, sandboxes, UAT, and staging environments seamlessly.

Q2: Does Smock-it help with GDPR compliance?
A: Absolutely. It generates synthetic data, removing the risk of exposing real customer information.

Q3: Is Smock-it customizable for different business objects?
A: Yes. You can use and extend templates to fit any Salesforce object or process.

Q4: How long does it take to set up?
A: Once prerequisites are configured, it takes just minutes to integrate into your GitHub workflows.

Q5: Can I monitor or download the generated data?
A: Yes. Smock-it outputs to data_gen/output/, which is uploaded as an artifact in your GitHub workflow.

Related Articles Salesforce QA & Testing

Concretio Contact Us Banner
Abhinav Gupta

First Indian Salesforce MVP, rewarded Eight times in a row, has been blogging about Salesforce, Cloud, AI, & Web3 since 2011. Founded 1st Salesforce Dreamin event in India, called “Jaipur Dev Fest”. A seasoned speaker at Dreamforce, Dreamin events, & local meets. Author of many popular GitHub repos featured in official Salesforce blogs, newsletters, and books.

https://abhinav.fyi
Next
Next

How to Create Test Data in Salesforce Using Smock-it?