Loading

Abort Apex test class execution using ApexTestQueueItems

Veröffentlichungsdatum: Oct 13, 2022
Beschreibung
"To abort a class that is in the Apex job queue, perform an update operation on the ApexTestQueueItem object and set its Status field to Aborted."

If you get the following error:
Unable to invoke async test job: This test is already in the execution queue.

You'll need to perform the below actions. 

In order to do this you can set the ApexTestQueueItems to aborted with the following Apex Code which you can run in Anonymous Apex:
Lösung
List<ApexTestQueueItem> items = [Select Id,ApexClassId,Status,ExtendedStatus,ParentJobId from ApexTestQueueItem where Status != 'Completed'];
for(ApexTestQueueItem atqi : items) {
    atqi.Status = 'ABORTED';
}
update items;

This will allow you to successfully abort the ApexTestQueueItems.
Nummer des Knowledge-Artikels

000384395

 
Laden
Salesforce Help | Article