CompileAndTestRequest

The compileAndTest() call contains this object, a request with information about the Apex to be compiled.

A CompileAndTestRequest object has the following properties:

NameTypeDescription
checkOnlybooleanIf set to true, the Apex classes and triggers submitted are not saved to your organization, whether or not the code successfully compiles and unit tests pass.
classesstringContent of the class or classes to be compiled.
deleteClassesstringName of the class or classes to be deleted.
deleteTriggersstringName of the trigger or triggers to be deleted.
runTestsRequestRunTestsRequestSpecifies information about the Apex to be tested. If this request is sent in a production organization, this property is ignored and all unit tests are run for your entire organization.
triggersstringContent of the trigger or triggers to be compiled.

Note the following about this object:

  • This object contains the RunTestsRequest property. If the request is run in a production organization, the property is ignored and all tests are run.
  • If any errors occur during compile, delete, testing, or if the goal of 75% code coverage is missed, no classes or triggers are saved to your organization. This is the same requirement as Salesforce AppExchange package testing.
  • All triggers must have code coverage. If a trigger has no code coverage, no classes or triggers are saved to your organization.