Filter Test Discovery API Results with the testLevel Parameter

Use the testLevel query parameter in the Test Discovery API to filter which test methods are returned based on their test level. The testLevel parameter replaces the showAllMethods parameter in API version 68.0 and later. The deprecated showAllMethods parameter is available only in API version 67.0 and earlier.

Where: This parameter is available in API version 68.0 and later. The Test Discovery API is available in Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

Why: The testLevel query parameter aligns with the testLevel request body parameter for the Test Runner API. To return all tests in the org regardless of namespace, set the value to RunAllTestsInOrg. To return tests in the org’s namespace, as well as flow tests, set the value to RunLocalTests. If the parameter isn’t specified, the test level defaults to RunAllTestsInOrg.

How: Make a GET request to the /services/data/v68.0/tooling/tests Tooling API endpoint, and specify the testLevel as a request query parameter.

For example, this request queries for unit tests in the org’s namespace and the FlowTesting namespace. It excludes tests that originate from installed managed packages.

/services/data/v68.0/tooling/tests?testLevel=RunLocalTests