---
title: "Exporting Test Execution"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44565732/Exporting%20Test%20Execution"
format: markdown
---
<details>
<summary>Table of Contents</summary>

> Macro (toc)
</details>

# Introduction

From a [**Test Execution**](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565117), it's possible to export the following Xray data: [**Tests**](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565156)** **and** **[**Test Runs**](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565109)**.**

In addition to the usual Jira mappings, you can export the following field: *TestEnvironments*

##### **Some mappings you can export from a Test Execution**

```
Key: ${Key}
Description: ${Description}
Test Environments: ${TestEnvironments}

#Overall Execution Status (percentage + total of testes per status)
TO DO: ${Overall Execution Status.TO DO.Percentage}% - ${Overall Execution Status.TO DO.Count}
EXECUTING: ${Overall Execution Status.EXECUTING.Percentage}% - ${Overall Execution Status.EXECUTING.Count}
PASSED: ${Overall Execution Status.PASSED.Percentage}% - ${Overall Execution Status.PASSED.Count}
FAILED: ${Overall Execution Status.FAILED.Percentage}% - ${Overall Execution Status.FAILED.Count}
ABORTED: ${Overall Execution Status.ABORTED.Percentage}% - ${Overall Execution Status.ABORTED.Count}
```

# Exporting Data

## Exporting Tests from a Test Execution

Below is an example of how to iterate over the list of **Tests** associated with a **Test Execution.**

##### **Iterate over Tests**

```
Total number of associated tests: ${TestsCount}

// Iterating each test
#{for tests}
	Key: ${Tests[n].Key}
	Test Status: ${Tests[n].TestStatus}
	// Iterating over test steps for each test
	#{for m=Tests[n].TestStepsCount}
		Action: ${Tests[n].TestSteps[m].Action}
		Data: ${Tests[n].TestSteps[m].Data}
		Expected Result: ${Tests[n].TestSteps[m].ExpectedResult}
	#{end}
#{end}
 
or
 
// Iterating each test
#{for j=TestsCount}
	Key: ${Tests[j].Key}
	Test Status: ${Tests[j].TestStatus}
	// Iterating over test steps for each test
	#{for m=Tests[j].TestStepsCount}
		Action: ${Tests[j].TestSteps[m].Action}
		Data: ${Tests[j].TestSteps[m].Data}
		Expected Result: ${Tests[j].TestSteps[m].ExpectedResult}
	#{end}
#{end}
```

> ℹ️ For more detailed information on how to export Tests and their information please check the page [Exporting Test](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44574749).

## Exporting Test Plans from a Test Execution

Below is an example of how to iterate over the list of **Test Plans** associated with a **Test Execution.**

##### **Iterate over Test Plans**

```
Total number of associated test plans: ${TestPlansCount}

// Iterating each test plan
#{for testPlans}
	Summary: ${TestPlans[n].Summary}
#{end}
 
or
 
// Iterating each test plan
#{for j=TestPlansCount}
	Description: ${TestPlans[j].Description}
#{end}
```

> ℹ️ Go here to see more about how to export [Test Plans](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565153).

## Exporting Test Runs from a Test Execution

Below is an example of how to iterate over the list of **Test Runs** associated with a **Test Execution.**

##### **Iterate over Test Runs**

```
Total number of associated test runs: ${TestRunsCount}

// Iterating each test run
#{for testruns}
    Assignee Id: ${TestRuns[n].AssigneeId}
    Key: ${TestRuns[n].Key}
    Summary: ${TestRuns[n].Summary}
    Comment: ${TestRuns[n].Comment}
    Generic Test Definition: ${TestRuns[n].Generic Test Definition}
    Cucumber Scenario: ${TestRuns[n].Cucumber Scenario}
    Executed by: ${fullname:TestRuns[n].Executed By}
    Execution Status: ${TestRuns[n].Execution Status}
    Started on: ${TestRuns[n].Started On}
    Finished on: ${TestRuns[n].Finished On}
    Test Version Name: ${TestRuns[n].TestVersion.Name}
    Test Version Id: ${TestRuns[n].TestVersion.Id}
    Test Version Number: ${TestRuns[n].TestVersion.Number}
    Test Version Created: ${TestRuns[n].TestVersion.Created}
    Test Version Updated: ${TestRuns[n].TestVersion.Updated}
    Test Version Author: ${TestRuns[n].TestVersion.Author}
    Test Version Author Id: ${TestRuns[n].TestVersion.AuthorId}
    Test Version Author Email Address: ${TestRuns[n].TestVersion.AuthorEmailAddress}   
    Test Version Is Default: ${TestRuns[n].TestVersion.IsDefault}
    Test Version Is Archived: ${TestRuns[n].TestVersion.IsArchived}

	// Replace the placeholder text to export any custom field associated with the test step.
	Test Run Custom Field:${TestRuns[n].<Test Run Custom Field>}

    // Iterating over execution evidences for each test run
    Execution Evidences Total: ${TestRuns[n].ExecutionEvidencesCount}
    #{for m=TestRuns[n].ExecutionEvidencesCount}
        Id: ${TestRuns[n].ExecutionEvidences[m].Id}
        Name: ${TestRuns[n].ExecutionEvidences[m].Name}
        Size: ${TestRuns[n].ExecutionEvidences[m].Size}
        HumanReadableSize: ${TestRuns[n].ExecutionEvidences[m].HumanReadableSize}
        Created: ${TestRuns[n].ExecutionEvidences[m].Created}
        MimeType: ${TestRuns[n].ExecutionEvidences[m].MimeType}
        Evidence: ${TestRuns[n].ExecutionEvidences[m].Evidence}
        FileURL: ${TestRuns[n].ExecutionEvidences[m].FileURL}
    #{end}

    // Iterating over execution defects for each test run
    Execution Defects Total: ${TestRuns[n].ExecutionDefectsCount}
    #{for m=TestRuns[n].ExecutionDefectsCount}
        Id: ${TestRuns[n].ExecutionDefects[m].Id}
        Description: ${TestRuns[n].ExecutionDefects[m].Description}
        Key: ${TestRuns[n].ExecutionDefects[m].Key}
        Summary: ${TestRuns[n].ExecutionDefects[m].Summary}
    #{end}

	// Iterating over parameters for each test run
    Parameters Total: ${TestRuns[n].ParametersCount}
	#{for m=TestRuns[n].ParametersCount}
        Key: ${TestRuns[n].Parameters[m].Key}
        Value: ${TestRuns[n].Parameters[m].Value}
    #{end}

	// Iterating over preconditions for each test run
	Preconditions Total: ${TestRuns[n].PreConditionsCount}
	#{for m=TestRuns[n].PreConditionsCount}
		Definition: ${TestRuns[n].PreConditions[m].PreCondition.Definition}
		Type: ${TestRuns[n].PreConditions[m].PreCondition.Type}
	#{end}

    // Iterating over test steps for each test run
    Test Steps Total: ${TestRuns[n].TestStepsCount}
    #{for m=TestRuns[n].TestStepsCount}
        Action: ${TestRuns[n].TestSteps[m].Action}
        Comment: ${TestRuns[n].TestSteps[m].Comment}
        Data: ${TestRuns[n].TestSteps[m].Data}
        Expected Result: ${TestRuns[n].TestSteps[m].ExpectedResult}
		Actual Result: ${TestRuns[n].TestSteps[m].ActualResult}
        Status: ${TestRuns[n].TestSteps[m].Status}
        Step Number: ${TestRuns[n].TestSteps[m].StepNumber}
		// Replace the placeholder text to export any custom field associated with the test step.
		Step Custom Field:${TestRuns[n].TestSteps[m].<Step Custom Field>}
        // Iterating over attachments for each test step
        #{for l=TestRuns[n].TestSteps[m].AttachmentsCount}
            Id: ${TestRuns[n].TestSteps[m].Attachments[l].Id}
            Name: ${TestRuns[n].TestSteps[m].Attachments[l].Name}
            Image: ${TestRuns[n].TestSteps[m].Attachments[l].Image}
            FileURL: ${TestRuns[n].TestSteps[m].Attachments[l].FileURL}
        #{end}
        // Iterating over evidences for each test step
        #{for l=TestRuns[n].TestSteps[m].EvidencesCount}
            Id: ${TestRuns[n].TestSteps[m].Evidences[l].Id}
            Name: ${TestRuns[n].TestSteps[m].Evidences[l].Name}
			Size: ${TestRuns[n].TestSteps[m].Evidences[l].Size}
			HumanReadableSize: ${TestRuns[n].TestSteps[m].Evidences[l].HumanReadableSize}
			Created: ${TestRuns[n].TestSteps[m].Evidences[l].Created}
			MimeType: ${TestRuns[n].TestSteps[m].Evidences[l].MimeType}
			Evidence: ${TestRuns[n].TestSteps[m].Evidences[l].Evidence}
			FileURL: ${TestRuns[n].TestSteps[m].Evidences[l].FileURL}
        #{end}
        // Iterating over defects for each test step
        #{for l=TestRuns[n].TestSteps[m].DefectsCount}
            Description: ${TestRuns[n].TestSteps[m].Defects[l].Description}
            Id: ${TestRuns[n].TestSteps[m].Defects[l].Id}
            Key: ${TestRuns[n].TestSteps[m].Defects[l].Key}
            Summary: ${TestRuns[n].TestSteps[m].Defects[l].Summary}
        #{end}
    #{end}
#{end}
```

### Exporting Parameterized Tests from a Test Run

To export all this data, you first need to execute the Test Run. 

If you change any data, you need to return to the Execution page and merge it with the new data.

| **Fields** | **Description** |
| --- | --- |
| *ParametersCount* | Total of Parameters declared in the Dataset |
| *IsDataDriven* | Returns "true" if the current test run is data-driven; otherwise, it returns "false" |
| *IterationsOverallExecutionStatus* | List of all the statuses in the current test run iteration and their percentages |
| *IterationsOverallExecutionStatus.STATUS.Count* | The number of STATUS in the Test Run iterations |
| *Iterations Overall Execution Status.STATUS.Percentage* | The percentage of STATUS in the Test Run iterations |
| *Parameters* | List of the Parameters from each Test Run iteration |


> ℹ️ **Data-driven**
> ℹ️ 
> ℹ️ The field *IsDataDriven* is going to return TRUE only if the Test Run has more than one iteration.

#### Exporting Test Runs Parameters from a Test Execution

For each Test Run Parameter you can export the following fields:

- *Key*
- *Value*

Below is an example of how to iterate over the list of **Test Run ****Parameters** associated with a **Test Execution.**

##### **Some mappings you can export from Test Runs Parameters**

```
// Iterating each test run
#{for testruns}
	// Iterating over parameters for each test run
    Parameters Total: ${TestRuns[n].ParametersCount}
	#{for m=TestRuns[n].ParametersCount}
        Key: ${TestRuns[n].Parameters[m].Key}
        Value: ${TestRuns[n].Parameters[m].Value}
    #{end}
#{end}
```

#### Exporting Test Runs Iterations from a Test Execution

For each Test Run Iteration, you can export the following fields:

- *Overall Execution Status*
- *Parameters from Test Run Iterations*
- *Test steps from Test Run Iterations*

Below is an example of how to iterate over the list of **Test Run Iterations** associated with a **Test Execution**.

##### **Some mappings you can export from Test Run Iterations**

```
// Iterating each test run
#{for testruns}
	IsDataDriven: ${TestRuns[n].IsDataDriven}	
	
	// Iterations Overall Execution Status (percentage + total of testes per status)
	List of Statuses: ${TestRuns[n].Iterations Overall Execution Status}
	TO DO: ${TestRuns[n].Iterations Overall Execution Status.TO DO.Percentage}% - ${TestRuns[n].Iterations Overall Execution Status.TO DO.Count}
    EXECUTING: ${TestRuns[n].Iterations Overall Execution Status.EXECUTING.Percentage}% - ${TestRuns[n].Iterations Overall Execution Status.EXECUTING.Count}
    PASSED: ${TestRuns[n].Iterations Overall Execution Status.PASSED.Percentage}% - ${TestRuns[n].Iterations Overall Execution Status.PASSED.Count}
    FAILED: ${TestRuns[n].Iterations Overall Execution Status.FAILED.Percentage}% - ${TestRuns[n].Iterations Overall Execution Status.FAILED.Count}
    ABORTED: ${TestRuns[n].Iterations Overall Execution Status.ABORTED.Percentage}% - ${TestRuns[n].Iterations Overall Execution Status.ABORTED.Count}

	// Iterating over test runs iterations
    Total of Iterations from a Test Run: ${TestRuns[n].IterationsCount}
	#{for m=TestRuns[n].IterationsCount}
		Name: ${TestRuns[n].Iterations[m].Name}
		Status: ${TestRuns[n].Iterations[m].Status}
		Parameters: ${TestRuns[n].Iterations[m].Parameters}

		// Iterating over parameters for each test run iteration
		Parameters Total: ${TestRuns[n].Iterations[m].ParametersCount}
		#{for l=TestRuns[n].Iterations[m].ParametersCount}
			Key: ${TestRuns[n].Iterations[m].Parameters[l].Key}
			Value: ${TestRuns[n].Iterations[m].Parameters[l].Value}
		#{end}

		// Iterating over preconditions for each test run iteration
    	Preconditions Total: ${TestRuns[n].Iterations[m].PreConditionsCount}
		#{for l=TestRuns[n].Iterations[m].PreConditionsCount}
     	    Definition: ${TestRuns[n].Iterations[m].PreConditions[l].PreCondition.Definition}
    	    Type: ${TestRuns[n].Iterations[m].PreConditions[l].PreCondition.Type}
    	#{end}

		//Iterating over test steps for each test run iteration
		#{for i=TestRuns[n].Iterations[m].TestStepsCount}
			Step Number: ${TestRuns[n].Iterations[m].TestSteps[i].StepNumber}
			Action: ${TestRuns[n].Iterations[m].TestSteps[i].Action}
			Data: ${TestRuns[n].Iterations[m].TestSteps[i].Data}
			Expected Result: ${TestRuns[n].Iterations[m].TestSteps[i].ExpectedResult}
			Status: ${TestRuns[n].Iterations[m].TestSteps[i].Status}
			Comment: ${TestRuns[n].Iterations[m].TestSteps[i].Comment}
			Actual Result: ${TestRuns[n].Iterations[m].TestSteps[i].ActualResult}
			
			// Iteration Test Step Attachments
			#{for l=TestRuns[n].Iterations[m].TestSteps[i].AttachmentsCount}
				Id: ${TestRuns[n].Iterations[m].TestSteps[i].Attachments[l].Id}
				Name: ${TestRuns[n].Iterations[m].TestSteps[i].Attachments[l].Name}
				Image: ${TestRuns[n].Iterations[m].TestSteps[i].Attachments[l].Attachment}
				FileURL: ${TestRuns[n].Iterations[m].TestSteps[i].Attachments[l].FileURL}
			#{end}
			// Iteration Test Step Evidences
			#{for l=TestRuns[n].Iterations[m].TestSteps[i].EvidencesCount}
				Id: ${TestRuns[n].Iterations[m].TestSteps[i].Evidences[l].Id}
				Name: ${TestRuns[n].Iterations[m].TestSteps[i].Evidences[l].Name}
				File URL: ${TestRuns[n].Iterations[m].TestSteps[i].Evidences[l].FileURL}
				Evidence: ${TestRuns[n].Iterations[m].TestSteps[i].Evidences[l].Evidence}
			#{end}
			// Iteration Test Step Defects
			#{for l=TestRuns[n].Iterations[m].TestSteps[i].DefectsCount}
				Description: ${TestRuns[n].Iterations[m].TestSteps[i].Defects[l].Description}
				Id: ${TestRuns[n].Iterations[m].TestSteps[i].Defects[l].Id}
				Key: ${TestRuns[n].Iterations[m].TestSteps[i].Defects[l].Key}
				Summary: ${TestRuns[n].Iterations[m].TestSteps[i].Defects[l].Summary}
			#{end}
		#{end}
	#{end}
#{end}
```

# Example

<span style="color: #172B4D"> shows an example with all the mappings available to export from a</span><span style="color: #172B4D"> </span>**Test Execution**<span style="color: #172B4D">:</span>


<details>
<summary>Support/Troubleshooting</summary>

If you have questions or technical issues, please [contact the Support team via the Customer Portal (Jira service management)](https://jira.getxray.app/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2Fcreate%2F28) or [send us a message using the in-app chat](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44577312).
</details>