---
schema_version: "1"
id: 28d17bc810d39ca21534f45cc134cf5bae309aaac16e668c699598a853d79707
title: ApexTestResult
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_apextestresult.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextestresult.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: d0b4ae752fa8c71eeaeb1879fa95f43a09e574294759401f6caa1c3b4110fe90
description: Repres ents the result of an Apex test method execution. This object is available in API version 23.0 and later.
---
# ApexTestResult

Repres ents 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

In API version 49.0 and later, 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.

This is a relationship field.

Relationship Name

ApexClass

Relationship Type

Lookup

Refers To

ApexClass



 |
| 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.

This is a relationship field.

Relationship Name

ApexLog

Relationship Type

Lookup

Refers To

ApexLog



 |
| ApexTestRunResultId | 

Type

reference

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The ID of the [ApexTestRunResult](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextestrunresult.htm "Contains summary information about all the test methods that were run in a particular Apex job. This object is available in API version 37.0 and later.") that represents the entire test run.

This is a relationship field.

Relationship Name

ApexTestRunResult

Relationship Type

Lookup

Refers To

ApexTestRunResult



 |
| 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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextestqueueitem.htm "Represents a single Apex class in the Apex job queue. This object is available in API version 23.0 and later.").

This is a relationship field.

Relationship Name

AsyncApexJob

Relationship Type

Lookup

Refers To

AsyncApexJob



 |
| IsTestSetup | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates if the results are for a test setup method. The default is false.





 |
| 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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextestqueueitem.htm "Represents a single Apex class in the Apex job queue. This object is available in API version 23.0 and later."), which is the class that this test method is part of.

This is a relationship field.

Relationship Name

QueueItem

Relationship Type

Lookup

Refers To

ApexTestQueueItem



 |
| 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.





 |
| TestCategory | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

The category of the test class. This field is available in API version 65.0 and later.

Possible values are:

- Apex—run Apex tests.
- Flow—run flow tests.
- IntegrationTest—run integration tests. This field is available as a Developer Preview in API version 67.0 and later. See [Apex Integration Tests for Agentforce and Data 360 Services (Developer Preview)](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_testing_integration_testing.htm) in the Apex Developer Guide.





 |
| TestName | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The name of the test class. This field is available in API version 65.0 and later.





 |
| TestNamespace | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The namespace of the test class.

Apex tests are in the default namespace, so theTestNamespace value for Apex tests is null.

Flow tests are in the [FlowTesting](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_namespace_flowtesting.htm) namespace. If a flow test is in a namespaced package or org, the TestNamespace value is FlowTesting.<NamepacePrefix>.

This field is available in API version 65.0 and later.





 |
| 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 ApexTestResult record represents a single test method execution. 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](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_apextestresultlimits.htm "Captures the Apex test limits used for a particular test method execution. An instance of this object is associated with each ApexTestResult record. This object is available in API version 37.0 and later.") record, which captures the Apex limits used during execution of the test method.