Newer Version Available

This content describes an older version of this product. View Latest

ApexTestResult

Represents the result of an Apex test method execution. This object is available in API version 23.0 and later.

Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

Special Access Rules

The enableApexTestReqViewSetup field on the ApexSettings metadata type controls the activation of the critical update “Require View Setup permission to access Apex test data”. In API version 49.0 and later, when the field is set to true, users must have the View Setup and Configuration permission to access this object.

Fields

Field Name Details
ApexClassId
Type
reference
Properties
Create, Filter, Group, Sort, Update
Description

The Apex class whose test methods were executed.

ApexLogId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

Points to the ApexLog for this test method execution if debug logging is enabled; otherwise, null.

ApexTestRunResultId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

The ID of the ApexTestRunResult that represents the entire test run.

AsyncApexJobId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

Points to the AsyncApexJob that represents the entire test run.

This field points to the same object as ApexTestQueueItem.ParentJobId.

Message
Type
string
Properties
Create, Filter, Nillable, Sort, Update
Description

The exception error message if a test failure occurs; otherwise, null.

MethodName
Type
string
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

The test method name.

Outcome
Type
picklist
Properties
Create, Filter, Group, Restricted picklist, Sort, Update
Description
The result of the test method execution. Can be one of these values:
  • Pass
  • Fail
  • CompileFail
  • Skip
QueueItemId
Type
reference
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

Points to the ApexTestQueueItem which is the class that this test method is part of.

RunTime
Type
int
Properties
Create, Filter, Group, Nillable, Sort, Update
Description

The time it took the test method to run, in milliseconds.

StackTrace
Type
string
Properties
Create, Filter, Nillable, Sort, Update
Description

The Apex stack trace if the test failed; otherwise, null.

TestTimestamp
Type
dateTime
Properties
Create, Filter, Sort, Update
Description

The start time of the test method.

Usage

You can query the fields of the ApexTestResult record that corresponds to a test method executed as part of an Apex class execution.

Each test method execution is represented by a single ApexTestResult record. For example, if an Apex test class contains six test methods, six ApexTestResult records are created. These records are in addition to the ApexTestQueueItem record that represents the Apex class.

Each ApexTestResult record has an associated ApexTestResultLimits record, which captures the Apex limits used during execution of the test method.