# Apex Tests

Manage apex tests in a package or a org

* [`sfp apextests trigger`](#sfp-apextests-trigger)

## `sfp apextests trigger`

Triggers Apex unit test in an org. Supports test level RunAllTestsInPackage, which optionally allows validation of individual class code coverage

```
USAGE
  $ sfp apextests trigger -o <value> [--json] [--loglevel
    trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL] [--apiversion <value>] [-l
    RunSpecifiedTests|RunApexTestSuite|RunLocalTests|RunAllTestsInOrg|RunAllTestsInPackage|RunAllTestsInDomain] [-n
    <value>...] [-r <value>] [-c] [--validatepackagecoverage] [--specifiedtests <value>] [--apextestsuite <value>] [-p
    <value>] [-w <value>] [--commitsha <value>] [-r <value>] [--outputformat raw|dashboard|both] [--environment <value>]

FLAGS
  -c, --validateindividualclasscoverage  Validate that individual classes have a coverage greater than the minimum
                                         required percentage coverage, only available when test level is
                                         RunAllTestsInPackage
  -l, --testlevel=<option>               [default: RunLocalTests] The test level of the test that need to be executed
                                         when the code is to be deployed
                                         <options: RunSpecifiedTests|RunApexTestSuite|RunLocalTests|RunAllTestsInOrg|Run
                                         AllTestsInPackage|RunAllTestsInDomain>
  -n, --package=<value>...               Name of the package to run tests. Required when test level is
                                         RunAllTestsInPackage
  -o, --targetusername=<value>           (required) Username or alias of the target org.
  -p, --coveragepercent=<value>          [default: 75] Minimum required percentage coverage, when validating code
                                         coverage
  -r, --releaseconfig=<value>            Path to the release config file(s) to test all packages within the domain
  -r, --repourl=<value>                  Custom source repository URL to use in artifact metadata, overrides origin URL
                                         defined in git config
  -w, --waittime=<value>                 Wait time in minutes for command to finish. Use 0 or omit for indefinite wait
      --apextestsuite=<value>            comma-separated list of Apex test suite names to run
      --apiversion=<value>               Override the api version used for api requests made by this command
      --commitsha=<value>                Commit SHA to use while reporting test results in markdown format
      --environment=<value>              Environment name for dashboard format (defaults to target org alias)
      --loglevel=<option>                [default: info] logging level for this command invocation
                                         <options: trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL>
      --outputformat=<option>            [default: raw] Output format for test results
                                         <options: raw|dashboard|both>
      --specifiedtests=<value>           comma-separated list of Apex test class names or IDs and, if applicable, test
                                         methods to run
      --validatepackagecoverage          Validate that the package coverage is greater than the minimum required
                                         percentage coverage, only available when test level is RunAllTestsInPackage

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Triggers Apex unit test in an org. Supports test level RunAllTestsInPackage, which optionally allows validation of
  individual class code coverage

EXAMPLES
  $ sfp apextests:trigger -o scratchorg -l RunLocalTests -s

  $ sfp apextests:trigger -o scratchorg -l RunAllTestsInPackage -n <mypackage> -c
```

*See code:* [*src/commands/apextests/trigger.ts*](https://source.flxbl.io/flxbl/sfp-pro)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp/cli-reference-v50-and-below/utilities/apex-tests.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
