Testing consists of 13% of total score in Salesforce Platform Lifecycle and Deployment Architect Exam. The topic covers testing methodologies, automated testing, unit testing, and testing strategy.

NOTE

Most of the content in this work was generated with the assistance of AI and carefully reviewed, edited, and curated by the author. If you have found any issues with the content on this page, please do not hesitate to contact me atΒ support@issacc.com.

🧭 Testing in Salesforce β€” Overview

Goal: Choose and run the right testing methodology (manual vs automated; unit β†’ UAT β†’ performance), meet coverage requirements, and manage representative, secure test data across the lifecycle.


🧱 Two Main Categories of Testing

CategoryWhat it isWhen to useProsCons
ManualHumans execute tests (click paths, subjective checks)Exploratory, UX/usability, one-off scenariosHuman judgment, flexibleSlow, repetitive, error-prone, hard to scale
AutomatedTools/scripts run tests at scaleRegression, CI/CD, data-driven, repeatable flowsFast, consistent, scalableUpfront setup, maintenance of scripts

Tools

Automated examples: Selenium, Copado, Provar, ACCELQ, UTAM, WebdriverIO, Jest (LWC).


πŸ§ͺ Testing Methodologies (What to run)

MethodPurposeTypical OwnerWhere
UnitVerify smallest pieces (Apex methods, flows, controllers) in isolationDevsDev/SBX
IntegrationVerify interactions (Apex ↔ external APIs, components)DevsSBX
SystemEnd-to-end of full Salesforce app/configQA/DevsSBX
FunctionalFeature works per spec/requirementsQA/BASBX
UATMeets business needs in real scenariosEnd users/POFull/partial copy SBX
RegressionNew changes don’t break old behaviorQA/DevOpsCI/CD SBX
Production (Smoke)Verify deployment worked in prodDevOpsPROD (lightweight only)
PerformanceApp performance & scalability under loadPerf/DevOpsSBX only
LoadExpected traffic/volumePerf/DevOpsSBX
StressBeyond expected limits to find breaking pointsPerf/DevOpsSBX

🧩 Unit Testing (Apex) β€” Must-knows

  • @isTest classes/methods; test classes don’t count toward 6 MB Apex limit.
  • Code coverage: β‰₯ 75% overall required to deploy Apex; each class/trigger must compile and have some coverage.
  • No emails, no real callouts in tests.
  • Use HttpCalloutMock + Test.setMock() for HTTP callouts.
  • Reset limits: Test.startTest() … code under test … Test.stopTest() β†’ fresh governor limits for the block.
  • Data isolation: Avoid @IsTest(SeeAllData=true); generate your own test data.
  • Helpful: Limits methods to inspect consumption (heap, DML, callouts, etc.).

πŸ‘©β€πŸ’Ό UAT β€” Don’t miss requirements

  • Run by end users in full/partial copy sandboxes.
  • Use a Requirements Traceability Matrix (RTM) to ensure every requirement has test cases and nothing is missed.

Why RTM?

Maps requirements ↔ test cases so coverage is explicit and auditable.


πŸš€ Performance / Load / Stress Testing (Salesforce rules)

  • Sandbox only (multi-tenant platform).
  • Request approval from Salesforce Support β‰₯ 2 weeks in advance with business justification.
  • Salesforce monitors activity, doesn’t design or interpret results.
  • Build a test plan (scenarios, success criteria).
  • Use built-ins for insight: Developer Console, Lightning Usage App, Salesforce Optimizer.
  • Keep governor limits and integration constraints in mind.

Production is off-limits

Performance, load, and stress testing are not permitted in production.


πŸ€– Automated Testing in CI/CD

  • Run unit + functional suites on merge to main branches to prevent regression.
  • For deployments via Metadata API, you can run a subset of tests using RunSpecifiedTests (pass test classes, not methods, in DeployOptions).
  • Fail deployment if any specified test fails or if < 75% coverage for changed Apex.

🧰 Test Execution β€” Tools & Options

AreaOptions / Notes
Run testsApex Test Execution page, Apex Classes page (Run All), Dev Console, VS Code, Code Builder, API (Tooling REST/SOAP)
GroupingsSingle class, suite, set of classes, all tests
Deploy test levelsDefault / Run Local Tests / Run All Tests / Run Specified Tests (Metadata API)
Coverage mathCCP = covered / (covered + uncovered) Γ— 100; comments/braces/class names/debug lines don’t count

Quick deploy time saver

Validate first, then use quick deploy (Change Sets) when appropriate; with Metadata API, use RunSpecifiedTests.


⚑ Testing Lightning

πŸ”· Lightning Web Components (LWC) with Jest

  • Runs locally (not in browser, no org), fast feedback with watch mode.
  • Test public API, DOM, events, simple interactions.
  • In each test: createElement('c-foo', { is: Foo }) β†’ document.body.appendChild(el) β†’ assert via el.shadowRoot.
  • Reset DOM in afterEach().
  • For wire: use @salesforce/sfdx-lwc-jest test utilities and local JSON mocks.
  • Test async DOM updates with Promises/await.

🟣 Aura Components

  • JS testing with Jest/UTAM/Mocha/WebdriverIO/Selenium.
  • Accessibility checks (missing alt, header scope, etc.) in JavaScript and WebDriver environments.
  • Server-side Apex logic tested separately with Apex test classes.

πŸ” Unified Test Data Strategy (Representative + Secure)

Why: Consistent, realistic, and compliant test data across Dev β†’ Test β†’ Staging β†’ Prod.

ElementPractices
RepresentativenessMirror prod shape/volume (entities, relationships, edge cases)
Security & ComplianceData Mask in sandboxes; masking/anonymization/pseudonymization for PII/PHI (GDPR/HIPAA)
CreationData factories, scripts; Bulk API/Data Loader for volume
AutomationScheduled loads for reliability; no human oversight needed
Relationships at scaleREST Composite & sObject Tree requests insert multiple related records in one transaction
Sandbox strategyChoose Dev, Dev Pro, Partial, Full based on stage & data needs
RefreshRegularly refresh from prod; define refresh cadence & approvals
CleanupBatch Apex to purge test data (e.g., nightly reset of partial copy)
Monitoring/AuditingTrack access/usage; periodic audits for policy adherence

Common pitfalls

Using live prod data unmasked, relying on SeeAllData=true, stale sandbox data, and missing parent-child relationships in bulk loads.


🧩 Scenario Playbook (What to recommend)

ScenarioRecommendation
High daily volume REST service (150k orders, up to 20 line items)Performance + load testing in full copy sandbox with expected volumes; pre-approved by Salesforce
Apex HTTP callouts in testsImplement HttpCalloutMock, call Test.startTest() β†’ Test.setMock() β†’ invoke β†’ assert β†’ Test.stopTest()
CI/CD with shorter deploysRunSpecifiedTests on DeployOptions (classes only)
UAT completenessMaintain RTM to ensure all requirements are covered
Hitting governor limits in testsWrap critical invocations between startTest()/stopTest()
Automated browser tests for LWCUpdate tests when DOM changes across Salesforce releases
Sandbox nightly resetBatch Apex job to delete ~2 GB test data on schedule
Multi-object test dataUse REST Composite or sObject Tree to insert related graphs in one call
Prod slowdown concernsNever perf-test in prod; monitor via Optimizer/Usage App; tune queries/triggers

πŸ“Œ Quick Checklists

πŸ“ˆ Flow Charts

1) Pick the right testing type

flowchart TD
    A[Testing need] --> B[Unit]
    A --> C[Integration]
    A --> D[System]
    A --> E[User acceptance]
    A --> F[Regression]
    A --> G[Performance]
    G --> H[Load]
    G --> I[Stress]


2) Apex unit test flow

flowchart TD
    A[Start test] --> B[Create test data]
    B --> C[Start test block]
    C --> D[Need http callout mock]
    D --> E[Set mock object]
    D --> F[Invoke method under test]
    E --> F
    F --> G[Assert expected results]
    G --> H[Stop test block]
    H --> I[Done]


3) Deployment with run specified tests

flowchart TD
    A[Begin deployment] --> B[Choose test level]
    B --> C[Run specified tests]
    B --> D[Run local or all tests]
    C --> E[List test classes in deploy options]
    E --> F[Deploy]
    D --> F
    F --> G[Check failures and coverage]
    G --> H[Fail deployment]
    G --> I[Succeed deployment]


4) Performance testing approval

flowchart TD
    A[Plan scenarios and metrics] --> B[Use sandbox only]
    B --> C[Prepare business justification]
    C --> D[Submit for approval two weeks ahead]
    D --> E[Approval granted]
    D --> F[Approval not granted]
    E --> G[Execute load or stress tests]
    G --> H[Monitor with tools]
    H --> I[Analyze results]
    I --> J[Optimize and retest]
    F --> C

5) Unified test data strategy

flowchart TD
    A[Define data policy] --> B[Model representative data]
    B --> C[Mask or anonymize sensitive data]
    C --> D[Choose sandbox type]
    D --> E[Create data with factories]
    D --> F[Bulk load with data loader]
    D --> G[Generate mock data]
    E --> H[Insert related records with composite]
    F --> H
    G --> H
    H --> I[Automate loads and refresh]
    I --> J[Batch apex cleanup]
    J --> K[Monitor and audit access]

6) UAT with requirements traceability

flowchart TD
    A[Prepare uat sandbox] --> B[Build traceability matrix]
    B --> C[Map requirements to test cases]
    C --> D[Prepare uat testers]
    D --> E[Execute uat scenarios]
    E --> F[Record defects]
    F --> G[Fix and redeploy]
    G --> H[Retest until pass]
    H --> I[Business sign off]

7) Lwc unit testing with jest

flowchart TD
    A[Setup jest] --> B[Create test file]
    B --> C[Create element]
    C --> D[Append to document]
    D --> E[Simulate user action]
    E --> F[Assert shadow dom]
    F --> G[Wait for async if needed]
    G --> H[Cleanup after each]
    H --> I[Run in watch mode]

8) Aura component test strategy

flowchart TD
    A[Plan aura tests] --> B[Choose javascript framework]
    A --> C[Choose webdriver for end to end]
    B --> D[Write client side tests]
    C --> E[Run accessibility checks]
    D --> F[Test apex controllers with apex tests]
    E --> G[Report issues and fix]
    F --> G

πŸ“š Flashcards

🧩 Testing Categories


πŸ§ͺ Testing Types


βš™οΈ Apex Unit Testing Essentials


πŸ“Š Test Execution & Coverage


⚑ Testing Lightning Components


πŸš€ Performance Testing Rules


🧩 Unified Test Data Strategy