---
title: Robot Framework
description: Learn how to integrate Allure with Robot Framework tests to generate rich, interactive test reports. Follow step-by-step setup, test execution, and report generation guidance.
---

# Getting started with Allure Robot Framework

[![Allure Robot Framework pypi latest version](https://img.shields.io/pypi/v/allure-robotframework?style=flat "Allure Robot Framework pypi latest version")](https://pypi.org/project/allure-robotframework/)

Generate beautiful HTML reports using [Allure Report](https://allurereport.org/docs/) and your [Robot Framework](https://robotframework.org/) tests.

## Setting up

### 1. Prepare your project

1. Install the Allure Report command-line tool, if it is not yet installed in your operating system. Note that Allure Report requires Java, see the [installation instructions](/docs/v2/install/).

1. Open a terminal and go to the project directory. For example:

   ```bash
   cd /home/user/myproject
   ```

1. If necessary for your system configuration, activate the virtual Python environment for your project.

   For example, if the project uses a `venv` environment, the command to activate it may look like this:

   ```bash
   source .venv/bin/activate
   ```

   This step is not necessary if you are using the system Python environment.

1. Install the Allure Robot Framework integration.

   ```bash
   pip install allure-robotframework
   ```

### 2. Run tests

When running your tests, add the `--listener allure_robotframework` command-line argument. This will allow Allure Robot Framework to collect test results into the `output/allure` directory. To specify another path for the test results directory, add it after the listener name, separated by a colon.

If you are going to use the [test plans](#select-tests-via-a-test-plan-file), also add the `--prerunmodifier allure_robotframework.testplan` argument.

**Use default test results directory:**
```bash
python -m robot \
  --listener allure_robotframework \
  --prerunmodifier allure_robotframework.testplan \
  ./my_tests
```

**Use custom test results directory:**
```bash
python -m robot \
  --listener allure_robotframework:allure-results \
  --prerunmodifier allure_robotframework.testplan \
  ./my_tests
```

### 3. Generate a report

Finally, convert the test results into an HTML report. This can be done by one of two commands:

- `allure generate` processes the test results and saves an HTML report into the `allure-report` directory. To view the report, use the `allure open` command.

- `allure serve` creates the same report as `allure generate`, then automatically opens the main page of the report in a web browser.

## Writing tests

The Allure Robot Framework integration extends the standard reporting features of Robot Framework by providing additional capabilities for crafting more informative and structured tests. This section highlights key enhancements that can be utilized:

- **Metadata Annotation**: Enhance test reports with [descriptions, links, and other metadata](#specify-description-links-and-other-metadata).
- **Test Organization**: Structure your tests into [clear hierarchies](#organize-tests) for better readability and organization.
- **Step Division**: Break down keywords into smaller [test steps](#divide-a-test-into-steps) for easier understanding and maintenance.
- **Parametrized Tests**: Clearly describe the parameters for [parametrized tests](#describe-parametrized-tests) to specify different scenarios.
- **Attachments**: Automatically capture [screenshots and other files](#attach-screenshots-and-other-files) during test execution.
- **Test Selection**: Use a test plan file to [select which tests to run](#select-tests-via-a-test-plan-file), allowing for flexible test execution.
- **Environment Details**: Include comprehensive [environment information](#environment-information) to accompany the test report.

In most cases, you need to indicate to Allure Robot Framework that a certain property needs to be assigned to the test result. Most properties can be assigned in the suite file, via the Decorators API or via the Runtime API.

- **Suite file**: use the `[Tags]`, `Set Tags` or `Test Tags` keywords in the suite files (see [Tagging test cases](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tagging-test-cases) in the Robot Framework documentation) to assign various data to tests.

  When using the `[Tags]` or `Test Tags` keyword, the data is guaranteed to be added to the test result regardless of how the test itself runs.

  When using the `Set Tags` keyword, it is recommended to put it as close to the beginning of the test as possible. This way, the data will be added even if the test fails early.

  You can use either a colon or an equal sign to separate the value from the name, e.g., `allure.label.epic:Web interface` is identical to `allure.label.epic=Web interface`.

- **Decorators API**: add a Python decorator to a method that implements a Robot Framework keyword. When using this approach, the data is guaranteed to be added regardless of how the keyword itself runs.

- **Runtime API**: use Allure's functions to add data to the test result during the execution of a keyword. This approach allows for constructing the data dynamically.

  Note that it is recommended to call the Allure's functions as close to the beginning of the implementation as possible, e.g., in the first lines of the first keyword's implementation. This way, the data will be added even if the test fails early.

### Specify description, links and other metadata

There is a lot of [metadata](/docs/v2/readability/#description-links-and-other-metadata) you can add to each test so that it would appear in the report. See the [reference](/docs/robotframework-reference/#metadata) for more details.

**Suite file:**
```
*** Test Cases ***

Test Authentication
    [Tags]
    ...  allure.label.owner:John Doe
    ...  allure.label.severity:critical
    # ...
```

**Decorators API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
@allure.label('owner', 'John Doe')
@allure.severity('critical')
def test_authentication():
    ...
```

**Runtime API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    allure.dynamic.label('owner', 'John Doe')
    allure.dynamic.severity('critical')
    ...
```

### Organize tests

As described in [Improving navigation in your test report](/docs/v2/navigation/), Allure supports multiple ways to organize tests into hierarchical structures. Allure Robot Framework provides functions to assign the relevant fields to tests either by adding decorators or “dynamically” (same as for the [metadata fields](#specify-description-links-and-other-metadata)).

To specify a test's location in the [behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy):

**Suite file:**
```
*** Test Cases ***

Test Authentication
    [Tags]
    ...  allure.label.epic:Web interface
    ...  allure.label.feature:Essential features
    ...  allure.label.story:Authentication
    # ...
```

**Decorators API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
@allure.epic('Web interface')
@allure.feature('Essential features')
@allure.story('Authentication')
def test_authentication():
    ...
```

**Runtime API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    allure.dynamic.epic('Web interface')
    allure.dynamic.feature('Essential features')
    allure.dynamic.story('Authentication')
    ...
```

To specify a test's location in the [suite-based hierarchy](/docs/v2/navigation/#suite-based-hierarchy):

**Suite file:**
```
*** Test Cases ***

Test Authentication
    [Tags]
    ...  allure.label.parentSuite:Web interface
    ...  allure.label.suite:Essential features
    ...  allure.label.subSuite:Authentication
    # ...
```

**Decorators API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
@allure.parent_suite('Web interface')
@allure.suite('Essential features')
@allure.sub_suite('Authentication')
def test_authentication():
    ...
```

**Runtime API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    allure.dynamic.parent_suite('Web interface')
    allure.dynamic.suite('Essential features')
    allure.dynamic.sub_suite('Authentication')
    ...
```

To specify a test's location in the [package-based hierarchy](/docs/v2/navigation/#package-based-hierarchy):

**Suite file:**
```
*** Test Cases ***

Test Authentication
    [Tags]
    ...  allure.label.package:org.example
    ...  allure.label.testMethod:test_authentication()
    # ...
```

**Decorators API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
@allure.label('package', 'org.example')
@allure.label('testMethod', 'test_authentication()')
def test_authentication():
    ...
```

**Runtime API:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    allure.dynamic.label('package', 'org.example')
    allure.dynamic.label('testMethod', 'test_authentication()')
    ...
```

### Divide keywords into steps

Allure Robot Framework displays each keyword as a separate step in the test report. It also provides two ways of [creating sub-steps](/docs/steps/) from within the Python code: “decorated steps” and “context steps”, see the [reference](/docs/robotframework-reference/#test-steps).

**Decorated steps:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    navigate_to_the_website()
    for login, password in [['johndoe', 'qwerty'],
                            ['janedoe', 'pass123']]:
        try_to_authenticate(login, password)

@allure.step('Navigate to the website')
def navigate_to_the_website():
    ...

@allure.step('Try to authenticate as {login}')
def try_to_authenticate(login, password):
    ...
```

**Context steps:**
```python
import allure
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    with allure.step('Navigate to the website'):
        ...

    for login, password in [['johndoe', 'qwerty'],
                            ['janedoe', 'pass123']]:
        with allure.step(f'Try to authenticate as {login}'):
            ...
```

### Describe parametrized tests

When you pass arguments to a keyword in the suite file, Allure Report displays them as parameters for the corresponding step, see the [reference](/docs/robotframework-reference/#parametrized-tests).

```
*** Keywords ***
Try To Authenticate
    [Arguments]    ${login}    ${password}
    Log To Console    Trying to authenticate with ${login} and ${password}...
    # ...

*** Test Cases ***

Test Authentication
    Try To Authenticate    johndoe@example.com    qwerty
    Try To Authenticate    janedoe@example.com    pass123
```

### Attach screenshots and other files

You can [attach any sorts of files](/docs/attachments/) to your Allure report. For example, a popular way to make a report easier to understand is to attach a screenshot of the user interface at a certain point.

Allure Robot Framework provides various ways to create an attachment, both from existing files or generated dynamically, see the [reference](/docs/robotframework-reference/#attachments).

**Suite file:**
```
*** Settings ***
Library     AllureLibrary
Library     RequestsLibrary

*** Test Cases ***
Test Authentication
    # ...

    ${response}=  GET  https://example.com/image.png
    Attach  ${response.content}
    ...     name=Image  attachment_type=PNG

    Attach File  /path/to/image.png
    ...          name=Image  attachment_type=PNG
```

**Runtime API:**
```python
import allure
import requests
from robot.api.deco import keyword

@keyword('Test Authentication')
def test_authentication():
    ...

    png_bytes = requests.get('https://example.com/image.png').content
    allure.attach(png_bytes, name='img', attachment_type=allure.attachment_type.PNG)

    allure.attach.file('/path/to/image.png', name='img', attachment_type=allure.attachment_type.PNG)
```

### Select tests via a test plan file

If the `--prerunmodifier allure_robotframework.testplan` argument is used and the `ALLURE_TESTPLAN_PATH` environment variable points to an existing file, Robot Framework will only run tests listed in this file.

Here's an example of running tests according to a file named `testplan.json`:

**MacOS/Linux:**
```bash
export ALLURE_TESTPLAN_PATH=testplan.json
python -m robot \
  --listener allure_robotframework \
  --prerunmodifier allure_robotframework.testplan \
  ./my_tests
```

**Windows:**
```powershell
$Env:ALLURE_TESTPLAN_PATH = "testplan.json"
python -m robot \
  --listener allure_robotframework \
  --prerunmodifier allure_robotframework.testplan \
  ./my_tests
```

### Environment information

For the main page of the report, you can collect various information about the environment in which the tests were executed.

For example, it is a good idea to use this to remember the OS version and Python version. This may help the future reader investigate bugs that are reproducible only in some environments.

Images: /images/python/environment-allure3.png, /images/python/environment-allure2.png

To provide environment information, put a file named `environment.properties` into the test results directory (`output/allure` by default) after running the tests. See the example in [Environment file](/docs/how-it-works-environment-file/).

Note that this feature should be used for properties that do not change for all tests in the report. If you have properties that can be different for different tests, consider using [Parametrized tests](#describe-parametrized-tests).
