Loading

Abort Apex test class execution using ApexTestQueueItems

Udgivelsesdato: Oct 13, 2022
Beskrivelse
"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øsning
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.
Vidensartikelnummer

000384395

 
Indlæser
Salesforce Help | Article