Loading

Abort Apex test class execution using ApexTestQueueItems

게시 일자: Oct 13, 2022
상세 설명
"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:
솔루션
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.
Knowledge 기사 번호

000384395

 
로드 중
Salesforce Help | Article