How to control which Apex tests run on a full deploy
Narrow a full deploy's Apex test run to a curated suite or a class list. For why a curated suite exists and how it relates to delta deploys, see curated test suites vs RunRelevantTests.
Does not apply to delta deploys
The delta leg always runs RunRelevantTests; none of the flags or variables below affect it
(deploy flags).
Know the default
Unless told otherwise, deploy / deploy validate run RunLocalTests. Override it per run with
--test-level (alias --testlevel), or set it once for an environment with the TEST_LEVEL
repository variable — the flag wins if both are present.
Generate a curated test suite
A curated suite is a fixed, named list of test classes stored as metadata. Build one from a source directory:
-d/--source-dir(required) — where to scan for@isTestclasses.-n/--name(required) — the suite name; the file is written toforce-app/main/default/testSuites/<name>.testSuite-meta.xml.--ignore-path(optional) — a gitignore-style file listing classes to leave out. The template ships.testsuiteignoreCifor this purpose.
Re-running the command overwrites the suite file with the current class list.
Commit the suite
The generated *.testSuite-meta.xml is ordinary metadata — commit it like any other force-app file
so the suite deploys with the rest of the project and CI can reference it by name.
Keep the suite fresh on Apex commits
A committed suite goes stale the moment a new Apex test class is added and nobody regenerates it. The
pre-commit step that would regenerate CiTestSuite from staged Apex classes ships opted out —
remove createapextestsuiteprecommit from .opt-out to have it regenerate on every Apex commit (see
opt-out keys). If you keep it opted out, regenerate the suite manually
(the command above) whenever the class list changes.
Deploy with the suite
Point a full deploy at the suite by name:
--test-suite-names (or the TEST_SUITE_NAMES repository variable) takes the suite name. Nothing
further to do — the orchestrator resolves the suite to its class list automatically whenever
--test-suite-names (or TEST_SUITE_NAMES) is set (see curated test suites vs
RunRelevantTests
for how).
Run a raw class list instead
Skip the suite file entirely and name classes directly:
Space-separate multiple classes in --tests (or the TESTS repository variable). Setting --tests
forces the effective test level to RunSpecifiedTests, regardless of what --test-level was set to.