> For the complete documentation index, see [llms.txt](https://docs.redefine.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redefine.dev/configuration/parallel-test-execution/redefine-parallel.md).

# Redefine Parallel

Redefine Parallel is Redefine's method of optimizing test distribution across multiple machines. It allows you to run tests as though they are being executed on a single machine while Redefine manages the distribution.

This approach utilizes test duration and failure probability to ensure that the most relevant tests are always running in parallel.

## Install

Follow the instructions in the [Quick Start ⏱️](/welcome-to-redefine/quick-start.md)guide to install Redefine.

## Configure

### Configure a shared session ID

To use Redefine Parallel, it is important to configure a shared session ID between all testing machines. This allows Redefine to connect the prediction and the execution of the tests.

Follow these steps to configure the shared Session ID:

1. It is crucial to generate the session ID once and provide it to all testing machines, to avoid misalignment. &#x20;
2. You can use the CLI command `redefine get session_id` to generate the session ID, which represents the current session.
3. Export the environment variable REDEFINE\_SESSION\_ID with the same value on all test-runners.

## Verify

Make sure that the verify command ends with success on all testing machines -

```bash
redefine verify --<testing-framework>
```

Follow the [Quick Start ⏱️](/welcome-to-redefine/quick-start.md#verify) guide for instructions and troubleshooting.

## Run

When executing the `redefine install` command, you need to pass the number of machines and the index of each machine to the Redefine command in the following format:

{% tabs %}
{% tab title="Pytest" %}

```bash
redefine install --pytest --<selection_mode> --splits <number of machines> --group <machine index>
pytest -n auto tests/
```

{% endtab %}

{% tab title="Cypress" %}

```bash
redefine install --cypress --<selection_mode> --splits <number of machines> --group <machine index>
npx run cypress
```

{% endtab %}

{% tab title="Mocha" %}

```bash
redefine install --mocha --<selection_mode> --splits <number of machines> --group <machine index>
npm run test
```

{% endtab %}
{% endtabs %}
