Filter Test Discovery API Results by Test Category

To retrieve only flow tests or only Apex tests, use the new category query parameter in calls to the Test Discovery API endpoint. Previously, you could filter tests only by namespace prefix and test method visibility. Filtering by test category is helpful in orgs with large test suites across different namespaces.

Where: This feature is available in API version 66.0 and later. This feature is available in Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

How: To retrieve tests in a specific test category, make a GET request to the Test Discovery API endpoint, which is a Tooling API resource. Set the category query parameter to either flow or apex. For example, this call returns only Apex tests.

https://MyDomain.my.salesforce.com/services/data/v66.0/tooling/tests?category=apex

You can’t specify multiple categories in the same call. However, you can combine the category query parameter with other query parameters. For example, this call returns only automated flow tests from the ourManagedPackage namespace.

https://MyDomain.my.salesforce.com/services/data/v66.0/tooling/tests?category=flow&namespacePrefix=ourManagedPackage