I just started setting up some Test Suites
, and I certainly like the convenience they afford. However, I cannot find a way to deploy them via Change Set
. Is it possible to deploy them in any way?
2 Answers
No, it does not look like they are available via Change Set as they are just data records in the ApexTestSuite
and TestSuiteMembership
tables. You will probably need to script the creation of the test suites in the target org in the same way that you would create data in Custom Settings, etc.
From the Force.com IDE Release Notes - Spring '16 Update:
To create or customize a test suite, use the Developer Console or the API. See Salesforce Help: Manage Sets of Apex Test Classes with Test Suites or
Object Reference for Salesforce and Force.com: ApexTestSuite, TestSuiteMembership.
Update:
Upon further reading, it looks like you can query them via SOQL but you must insert the records via an API call as DML is not allowed here. Sounds like they behave similarly to Custom Metadata records.
Insert a TestSuiteMembership object using an API call to associate an Apex class with an ApexTestSuite object. (ApexTestSuite and TestSuiteMembership aren’t editable through Apex DML.)
To remove the class from the test suite, delete the TestSuiteMembership object. If you delete an Apex test class or test suite, all TestSuiteMembership objects that contain that class or suite are deleted.
SFDC provided SOQL Query:
SELECT Id FROM TestSuiteMembership
WHERE ApexClassId = '01pD0000000Fhy9IAC'
AND ApexTestSuiteId = '05FD00000004CDBMA2'
-
Ah, hadn't assumed they were metadata. I guess it makes sense they would be data instead. I can't query them from the console, though. Can they be retrieved/uploaded?– Adrian Larson ♦Commented Mar 2, 2016 at 0:27
-
I can't query for them with or without
Tooling API
selected in the query editor. Any ideas on how to move them in an automated way?– Adrian Larson ♦Commented Mar 2, 2016 at 0:43 -
Not sure how to move them in an automated manner yet. When you say you can't query them, what was the query you used to do so? (I noticed one of the object names in the SFDC release notes quote is incorrect and updated the answer accordingly.) Commented Mar 2, 2016 at 0:48
-
I guess just
TestSuite
is giving me errors.TestSuiteMembership
does indeed seem to haveSOQL
support. I'll see if I can data load some records. Ah, d'oh! It'sApexTestSuite
. Figures.– Adrian Larson ♦Commented Mar 2, 2016 at 0:49 -
The object is actually
ApexTestSuite
. You will be able to query them but in order to deploy them into your other org, what you're actually deploying are metadata objects (you might be able to subscribe to them in Eclipse), not inserting records into these queryable tables via DML. Commented Mar 2, 2016 at 0:53
ApexTestSuite is now a formal type of metadata that can be retrieved and deployed from an org. See https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_apextestsuite.htm
-
1But apparently still not available in Change Sets. (Wonder if the SF product team figures that a team with sufficient maturity to use Test Suites wouldn't be using Change Sets for change management or what) Commented Dec 5, 2020 at 20:11