---
title: "Constraints"
canonical: "https://docs.getxray.app/space/XRAY/159712684/Constraints"
format: markdown
---
![Banner-Xray-Documentation-Enterprise.png](media://a2327258-351b-4326-9e9f-2a314db93a45)


> Macro (ui-expand)
> 
> > Macro (toc)

# Introduction

In certain [Scenarios](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/160137241), [Test Case Designer](https://getxraydocs.atlassian.net/wiki/spaces/XRAY/pages/160038931) allows you to define which Parameter values should never be tested together. This is achieved by applying Constraints.

To guide the model, you can define Invalid Constraints (values that should never be tested together) and/or Bound Constraints (values that must be tested together). Important - regardless of the constraint type, the only function of this feature is the **exclusion** of certain combinations from the Scenarios screen.

# Invalid Constraints

Invalid Constraints prevent parameter values that should never be combined in a Test case.

For example (Figure 1), assume that the browser Internet Explorer (IE) is not supported on Apple computers. In this case, it would be impossible to Test a scenario where IE is launched on a Mac running its native OS. Therefore, you want to prevent the generation of Test cases that combine *Mac* *OS* and *IE10 or IE11*.

![Figure 1 - Browser](media://7011728c-eb53-4e8e-a733-86e4f6538423)

## Creating Invalid Constraints

> Macro (ui-steps)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> > Macro (legacy-content)
> 
> <span style="color: #202020">As you use the Invalid Pair feature and the related Bound Pair, keep in mind these usage tips:</span>
> 
> > ✅ **Adding Many Invalid Constraints**
> > ✅ 
> > ✅ Imagine your app asks, *Would you like to add a hotel to your travel reservation?* Any Scenarios with *Do Not Add a Hotel* would require numerous Invalid Constraints between options like *Do Not Add a Hotel* and *Hotel Chain Preference = X*. In such cases, the Bound Constraint feature can help you handle constraints more efficiently.
> > ✅ 
> > ✅ If your model has more than 10 Invalid or Bound Constraints, it may be quicker to export your model into Excel to document paired values. To do this, follow these steps:
> > ✅ 
> > ✅ - Add multiple paired values in Xray Test Case Designer before exporting, so you can easily copy the formatting for Invalid or Bound Constraints.
> > ✅ - Ensure accurate spelling of values. Copying and pasting is safer than typing.
> > ✅ 
> > ✅ **Not Applicable Values**
> > ✅ 
> > ✅ Be cautious with multiple *Not Applicable* values in a model. For instance, does it make sense to create a Bound Constraint between *Hotel Chain Preference = Not Applicable* and *Type of Room = Not Applicable* ?

# <span style="color: #42526e">Bound Constraints</span>

Bound constraints restrict Parameter values that can only be tested together.

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

## Creating Bound Constraints

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

## One-way Bound Pair

**The underlying relationship type is many-to-one, represented by WHEN-THEN statements in the left column.**

<span style="color: #202020">We would like to exclude combinations like </span><span style="color: #202020">*Breed of Animal*</span><span style="color: #202020"> = </span><span style="color: #202020">*Shiba Inu*</span><span style="color: #202020"> and </span><span style="color: #202020">*Type of Animal = Cat*</span><span style="color: #202020"> from the generated scenarios. </span>

<span style="color: #202020">We have two breeds for each of the first two types of animals. Therefore, we can set up four one-way bound pairs from </span><span style="color: #202020">*Breed of Animal*</span><span style="color: #202020"> to </span><span style="color: #202020">*Type of Animal*</span><span style="color: #202020"> (Figure 16):</span>

![Figure 16 - Breed](media://322fca05-5a68-42c6-aa8f-1ac958e43de4)


<span style="color: #202020">You can check the logic by reading the statement at the bottom of the dialog (Figure 16 - 1).</span>

**The order in which you set the pair matters.**

In this case, we wouldn't be able to say WHEN <span style="color: #202020">*Type of Animal = Cat*</span><span style="color: #202020"> THEN </span><span style="color: #202020">*Breed of Animal = Siamese*</span><span style="color: #202020"> because that would prevent </span><span style="color: #202020">*Cat + Persian*</span><span style="color: #202020"> from appearing, and would leave </span><span style="color: #202020">*Persian*</span><span style="color: #202020"> without any possible pairing (Figure 18).</span>

![Figure 17 - Type](media://65fc7975-c89c-49cd-b234-0c7e5ea48e40)

> ⚠️ <span style="color: #202020">You may argue that the statement at the bottom (Figure 17 - 1) still looks correct in this direction. However, keep in mind how the algorithm </span><span style="color: #202020">*must*</span><span style="color: #202020"> interpret the word. Since the evaluation is done at the pair of values level, </span><span style="color: #202020">*must have Breed of Animal as Siamese*</span><span style="color: #202020"> = </span><span style="color: #202020">*must NOT have Breed as Persian, Shiba Inu, Golden Retriever, Arabian*</span><span style="color: #202020"> - of which </span><span style="color: #202020">*Persian*</span><span style="color: #202020"> is incorrectly excluded. Therefore, this direction wouldn't work for this example. We could use such direction if we had multiple types that can be with only one breed.</span>

## Mutually Bound Pair

**The underlying relationship type is one-to-one, represented by ALWAYS-ALWAYS statements in the left column.**

<span style="color: #202020">With Mutually Bound Constraints, the values are exclusive to each other. In this example (Figure 18), there is only one horse breed in the second parameter. So, with one constraint, we can specify that </span><span style="color: #202020">*Horse*</span><span style="color: #202020"> should not be paired with </span><span style="color: #202020">*Siamese, Persian, Shiba Inu, Golden Retriever,*</span><span style="color: #202020"> and </span><span style="color: #202020">*Arabian*</span><span style="color: #202020"> should not be paired with </span><span style="color: #202020">*Cat, Dog*</span><span style="color: #202020"> - i.e., </span><span style="color: #202020">*Horse*</span><span style="color: #202020"> and </span><span style="color: #202020">*Arabian*</span><span style="color: #202020"> must only be tested together.</span>

![Figure 18 - Breed](media://725cf97e-1a63-42f3-90e3-2f293f20f8d7)


The final set of rules for this model (in the verbal form) would look like this (Figure 19):

![Figure 19 - Final](media://0d9763e1-b2dc-4bd7-b5e0-cac9aa045e1c)


<span style="color: #202020">In essence, Bound Constraints and Invalid Constraints perform similar tasks: they ensure that certain values only or never appear together - making all generated scenarios valid within the model scope. From a different point of view, Bound Constraints and Mutually Bound Constraints actually invalidate many values and Invalid Constraints bind many values.</span>

# <span style="color: #202020">Skip Constraints</span>

> ℹ️ <span style="color: #202020">Skip constraints are only available under the Advanced Mode (toggle in the top left of the Constraints screen).</span>

  
<span style="color: #202020">Skip constraints allow for certain parameters to be excluded from Test cases when it is not appropriate for them to appear. It is a faster alternative to the </span><span style="color: #202020">*Not applicable*</span><span style="color: #202020"> + Bound Pairs approach. </span>

## Creating Skip Constraints

For example, let’s use the model below for a flight booking system (Figure 20):

![Figure 20 - Flight](media://270f2052-ade0-4f55-b9cc-d40abb0d21af)


<span style="color: #202020">In this model (Figure 20), only customers who are in First Class get in-flight dining. Coach and Business class customers do not get in-flight dining. Therefore, Test cases with Coach and Business class customers should have no value for </span><span style="color: #202020">*Food Choice*</span><span style="color: #202020">. Additionally, Coach customers do not even get </span><span style="color: #202020">*Drink Choice.*</span>

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

# <span style="color: #202020">Viewing a Constraint</span>

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

# <span style="color: #202020">Editing a Constraint</span>

> ℹ️ It is not possible to edit a Constraint in the Standard View. In the Standard View, you are only allowed to delete and create a new Constraint.

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

# <span style="color: #202020">Deleting a Constraint</span>

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

<span style="color: #202020"> </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/XRAY/pages/301501383).
</details>