Run Apex Tests Locally
glade test discovers Apex test classes from an SFDX project, compiles supported code, runs tests in the local VM, and reports stable outcomes. It uses the same project loader, parser, semantic analyzer, storage, DML, SOQL, trigger, and limit stack as the rest of the CLI.
Run all tests
glade test --project .Glade test
1 selected, 1 passed, 0 failed
Selected: 1
Passed: 1
Failed: 0
Runtime: 420ms
✓ RefinementServiceTest.testRefinesFileRow 42ms
Next:
glade test --watch
glade test failedMachine-readable output:
glade test --project . --json--json writes the versioned envelope described in Automation and JSON.
JUnit output for CI:
mkdir -p reports
glade test --project . --junit reports/glade-junit.xmlFilter tests
Run a test class:
glade test --project . --class RefinementServiceTestRun a single method:
glade test --project . --class RefinementServiceTest --method testRefinesFileRowUse exact class and method selectors for the short inner loop. Then run the wider suite before shipping.
Limit modes
Glade supports limit modes for local execution. strict enforces supported governor limits closer to Salesforce behavior. permissive keeps the local loop moving when a project depends on unfinished areas.
glade test --project . --limit-mode strict
glade test --project . --limit-mode permissive --jsonUse strict for gates. Use permissive when you are carving into unsupported terrain and want the next useful diagnostic.
Watch mode
Run tests on file changes:
glade test --project . --watchRun one affected-test pass and exit:
glade test --project . --watch-onceRun the daemon-backed watch loop:
glade test --project . --daemon --watchRun tests affected by a git ref without remembering the lower-level flag:
glade test changed --project . --since HEADRerun failures from the last completed run:
glade test failed --project .
glade test --project . --last-failedPrint the next likely loop commands without running tests:
glade test --project . --wizardLocal preview surfaces
LWC and Visualforce preview have their own workflow and product pages.
Warm startup across CLI runs
Large projects rebuild local org state and helper compilation on cold start. glade test writes that harness to .glade/test/startup.meta.json plus a hashed payload after the first cold build and reloads it when fingerprint checks pass.
Test Startup Cache explains when the cache is created, how it stays up to date, when it can be wrong, and how to recover.
glade test serve --project .
glade test daemon status --project .
glade test --project . --class RefinementServiceTest
glade test daemon stop --project .
glade test clear-cache --project .
glade test --project . --no-cache --class RefinementServiceTestClear the cache after git pull or Glade upgrades. Use --no-cache when debugging harness issues.
CI pattern
A small CI gate can check the project, run affected tests, then write JUnit output for test reporting:
glade check --project . --json
glade test changed --project . --since origin/main --json --no-progress
mkdir -p reports
glade test --project . --junit reports/glade-junit.xmlSaved run artifacts and CI annotations are covered in Add Glade to CI.
Outcomes
Local test runs separate assertion failures from load errors, compile errors, unsupported features, and internal errors. That split matters. A failing assertion means the test ran and failed. An unsupported feature means the runtime stopped at a known unsupported Salesforce API.
✓ RefinementServiceTest.testRefinesFileRow 42ms
✗ RefinementServiceTest.testRejectsBlankFileRow 12ms
RefinementServiceTest.testRejectsBlankFileRow
System.AssertException: expected 1, got 0
force-app/main/default/classes/RefinementServiceTest.cls:42Check what Glade runs locally before relying on platform service APIs, exact hosted Visualforce behavior, live side effects, or REST behavior outside the checked local baseline.
Try it
Exercise the runtime your tests rely on - DML, triggers, and governor limits - in the local playground:
glade playground --examples --addr 127.0.0.1:1789 --open