# Sequence Flow

## Basics

{% hint style="info" %}
To be able to control test sequence flow you need to create labels within the test sequence. To do that enter a desired name in the label column. When using #call \<label> and other commands the sequence will jump to the test step with the label
{% endhint %}

<figure><img src="/files/up2gbZn2Oq7S7Mvcq3et" alt=""><figcaption><p>An example of using a label that can be called by sequence flow commands such as #call </p></figcaption></figure>

## <mark style="color:blue;">#goto (Jump to label)</mark>

This command will jump to a test with specified label and continue the execution from there

### Command Overview

<table data-full-width="true"><thead><tr><th width="136">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="dd3ea796575b44beb6fe421f4c920096">#goto</span></td><td>&#x3C;label-name></td></tr></tbody></table>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="103">Type</th><th>Options</th></tr></thead><tbody><tr><td>label-name</td><td>[string]</td><td>Target label name to jump to. There is a special predefined label <code>@this</code> which represents the current row. This can be used to make the infinite main loop without defining any other label.</td></tr></tbody></table>

## <mark style="color:blue;">#call (Call a function)</mark>

This command will call a function (label) and expects a return value back. After the function is executed the sequence continues.

### Command Overview

<table data-full-width="true"><thead><tr><th width="369">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="ec3495f85035441f931d4da997acdf76" label="#call" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="ec3495f85035441f931d4da997acdf76">#call</span></td><td>&#x3C;label-name>{:&#x3C;param0>:....:&#x3C;paramn>}</td></tr></tbody></table>

{% hint style="info" %}
Call a function. Function is a block of code begins by the label and ends by the <mark style="color:blue;">`#return`</mark> (or <mark style="color:blue;">`#throw`</mark>) command. Typically the block should be placed outside the main program loop. The #call blocks the executing until subroutine is finished. The return value (<mark style="color:blue;">#return</mark> of sub-routine) is written to Return Value.
{% endhint %}

#### Example

In this example you can see a test step that calls "ICT" label. When executed the section labeled ICT is executed until the #return command is reached. Aftert that the value of the #return parameter is written to return value of #call step and the test step is finished

<figure><img src="/files/DL9isrYFCh8jIUERS9hE" alt=""><figcaption></figcaption></figure>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="115">Type</th><th>Options</th></tr></thead><tbody><tr><td>label-name</td><td>[string]</td><td>Target label name to jump to</td></tr><tr><td>param</td><td>[string]</td><td>Optional parameter(s) to pass to target function. This parameter (s) will be stored to the "Return Value" of the called function. If there is more than one parameter, they will be stored to following lines, one parameter to one line, overwriting previous values. Line(s) with parameters name should be set to nonexecute, otherwise the parameter(s) in the "Return Value" will be overwritten by a command after step is executed. <br><strong>Default:</strong> (empty)</td></tr></tbody></table>

## <mark style="color:blue;">#return(Jump from function)</mark>

This command represents the end of the function block.

### Command Overview

<table data-full-width="true"><thead><tr><th width="136">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="1576fb8a623240f6a5cd19b0086ec379" label="#return" color="blue"></option><option value="5d7a98d7acab42ebae94f38253cd4252" label="#throw" color="blue"></option><option value="6c4f0bb0151b47dfba70bb09cbe953b1" label="#onerror" color="blue"></option><option value="4456763d3e2e4df9a8fe186c05a233d0" label="#onfail" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="1576fb8a623240f6a5cd19b0086ec379">#return</span></td><td>{&#x3C;return-value>}</td></tr></tbody></table>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="103">Type</th><th>Options</th></tr></thead><tbody><tr><td>return-value</td><td>[string]</td><td>Optional parameter, function can return a blank value. Otherwise this is any value to be returned by a function block. <br><strong>Default</strong>: (empty)</td></tr></tbody></table>

## <mark style="color:blue;">#throw(Exit function with error)</mark>

Return from function with an error. This will cause ReturnStatus = 1 at the place of function calling (using #call). If the async-called function is exited by #throw, the error is passed to #sync function. It is possible to return a custom error message or pass last caught error by #onerror functionality.

### Command Overview

<table data-full-width="true"><thead><tr><th width="136">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="1576fb8a623240f6a5cd19b0086ec379" label="#return" color="blue"></option><option value="5d7a98d7acab42ebae94f38253cd4252" label="#throw" color="blue"></option><option value="6c4f0bb0151b47dfba70bb09cbe953b1" label="#onerror" color="blue"></option><option value="4456763d3e2e4df9a8fe186c05a233d0" label="#onfail" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="5d7a98d7acab42ebae94f38253cd4252">#throw</span></td><td>{&#x3C;message>}</td></tr></tbody></table>

#### Parameter Description

<table data-full-width="true"><thead><tr><th width="162.33333333333331">Parameter</th><th width="103">Type</th><th>Options</th></tr></thead><tbody><tr><td>message</td><td>[string]</td><td>Optional error message to return from the function. If no message is passed, the #throw command will return the last error, caught by #onerror functionality.</td></tr></tbody></table>

## <mark style="color:blue;">#onerror, #onfail (Check for error or fail)</mark>

These commands enables to check for an error (means Return Status <> 0) or fail (means Judge is not empty and <> 0).

{% hint style="info" %}
Note: On-fail action is not executed when the step ends with an error. If you want to treat both situations, you have to define behaviors for both on-fail and on-error (can be the same).
{% endhint %}

It is possible to: just set a number of retries of following step(s) perform a function call go to to a specified label

### Command Overview

<table data-full-width="true"><thead><tr><th width="208">Command<select><option value="69d37e59dbc44aaca6dc72161f84784b" label="#msg" color="blue"></option><option value="b928d283a7784fae8c94f7bc27467b23" label="#dlg" color="blue"></option><option value="dd3ea796575b44beb6fe421f4c920096" label="#goto" color="blue"></option><option value="1576fb8a623240f6a5cd19b0086ec379" label="#return" color="blue"></option><option value="5d7a98d7acab42ebae94f38253cd4252" label="#throw" color="blue"></option><option value="6c4f0bb0151b47dfba70bb09cbe953b1" label="#onerror" color="blue"></option><option value="4456763d3e2e4df9a8fe186c05a233d0" label="#onfail" color="blue"></option><option value="6c585f1a996d409ba9557f3357e94ec0" label="#onerror / #onfail" color="blue"></option></select></th><th>Parameter</th></tr></thead><tbody><tr><td><span data-option="6c585f1a996d409ba9557f3357e94ec0">#onerror / #onfail</span></td><td>see below in examples</td></tr></tbody></table>

### Examples

{% tabs %}
{% tab title="Example 1 " %}

<table data-full-width="true"><thead><tr><th width="174">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#onerror / #onfail</td><td>none</td></tr></tbody></table>

Disable the error or fail checking functionality.
{% endtab %}

{% tab title="Example 2" %}

<table data-full-width="true"><thead><tr><th width="240">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#onerror / #onfail</td><td>goto:error</td></tr></tbody></table>

If an error occurs, the funTEST go to a line labeled "error".
{% endtab %}

{% tab title="Example 3" %}

<table data-full-width="true"><thead><tr><th width="240">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#onerror / #onfail</td><td>goto:error:retry=3</td></tr></tbody></table>

If an error occurs the current line is repeated by a maximum of 3 times. If not success, then funTEST go to a line labeled "error".
{% endtab %}

{% tab title="Example 4" %}

<table data-full-width="true"><thead><tr><th width="240">Command</th><th>Parameter</th></tr></thead><tbody><tr><td>#onerror / #onfail</td><td>call:error_func:retry=3</td></tr></tbody></table>

Almost the same like above. The difference is, that the function is called there and program will continue from the line where an error has occurred.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://funtest-1.gitbook.io/funtest-documentation/creating-test-sequence/funtest-commands/sequence-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
