---
title: "Modular Tests"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44578265/Modular%20Tests"
format: markdown
---
<details>
<summary>Table of Contents</summary>

> Macro (toc)
</details>

# Introduction

Modular Test design is a way of promoting Test case **reusability** and **composition** across a large [Test repository](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565166). To design modular Tests, you can create a [manual Test](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565156) where some of the [Test Steps](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565316) call* *or include other Test Cases. This prevents Testers from having to write the same steps over and over again for different high-level Tests. Using a modular design approach, any Test can become a building block of a more extensive Test [scenario](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565557). Still, they can also be [executed](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565037) individually if needed.

A Call Test can, in turn, also call other Tests. You can compose a Test scenario with up to five levels of depth.

Modular Tests can also be [parameterized](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44566351). When calling a Test, you can provide new parameter values according to the parent Test data.

Upon execution, Xray will unfold all call Test Steps in the [Test Run](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565109). This becomes transparent to testers as they only have to follow and execute the steps on the execution, even though Test Steps might come from different Test Issues.

# Use Case

A common use case for modular Tests is end-to-end Testing. End-to-end Tests often need to pass through the same area or component of the application before asserting the final result.

With modular Test design, you can **reuse** the Tests for these common areas or components (Figure 1).

  


> Macro (gliffy)

Figure 1 - Modular Test

# Modular Tests Limitations

- [Precondition](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565159) Issues will be ignored when Tests are being called/included in other Tests.
- Modular Test design only works with manual Tests.
- The call context dataset for call Tests does not support multiple iterations.
- There is a depth limit of five call Tests: A → B → C → D → E.
- The total number of call Tests allowed for a given Test Run is 200.

# Designing Modular Tests

To start designing modular Tests, you first need to think about structure and reusability.

Once you have identified the individual building blocks for a given Test case, you need to consider if some blocks can originate separate Test Cases. If there are blocks that can be executed individually or later be reused for other Test scenarios, consider creating different Test Issues and composing the initial Test case with them.

> ℹ️ To create a Test Case composed of other Tests, you need to use **Call Test Steps**. Call Steps can be interchanged with common Test Steps to define a Test. Call Steps are represented by the purple color in Xray (Figure 1 - 3).

## Creating a Call Test Step

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

## Parameterizing Call Tests

It is possible to specify and override the parameter values for Call Tests. After defining the call Test Step, you can edit the dataset in this context. To define the test data for a Call Test:

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

## Importing Steps with Call Tests

Xray also supports importing Steps with Call Test Steps from the following sources:

- JSON.
- Test.
- CSV.
- Clipboard.

### JSON

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

### Test

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

### CSV

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

### From Clipboard

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

## Exporting Steps to a CSV File

When exporting Test Steps to a CSV file, the Call Test Steps and their parameters will also be included on the CSV file as distinct columns. 

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)

# Execution

When [executing Tests](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44565117) composed of modular Tests, Xray will unfold/expand all Steps and replace the parameters with their resolved values in the [Testing Board](https://getxraydocs.atlassian.net/wiki/spaces/XRAYCLOUD/pages/44579147).

On the Step number column, a warning (Figure 30 - 1) indicates when a Step belongs to another Test Issue. The users can click the Test Issue key to navigate to that Test.

![Figure 30 - Execution](media://a9fa4fc4-7b50-4038-be1c-fa5f0b4505c8)

## Parameter Resolution

When resolving the parameter values, Xray will try to get the parameter from the closest context. If the parameter is not found, Xray will search the parent context.

For a given parameter **P** within a call Test Step, the value of **P** will be resolved from the first of the following contexts where **P** is explicitly defined:

- The call context dataset for the Call Test.
- The call context dataset of the parent Call Test (current level >= 2).
- The **resolved** dataset for the Test Run (Test Run > Test Plan > Test).

  


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