# 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 %}


---

# 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://docs.redefine.dev/configuration/parallel-test-execution/redefine-parallel.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.
