---
title: "Scenario tests with behave"
description: "Tests written as scenarios that domain experts can read"
source: https://developer.remotivelabs.com/docs/get-started/examples/behave
last_updated: 2026-11-24
---

# Scenario tests with behave

- Goal: Test
- From: [RemotiveCar v0.9.0](https://github.com/remotivelabs/remotivelabs-remotive-car/tree/v0.9.0)
- Protocols: CAN
- Vehicle domains: Lighting

## Run it

```bash
git clone https://github.com/remotivelabs/remotivelabs-remotive-car.git
cd remotivelabs-remotive-car

remotive topology build \
  -f instances/hello_world/main.instance.yaml \
  -f settings/can_over_udp.settings.instance.yaml \
  build

docker compose -f build/remotive_car_hello_world/docker-compose.yml --profile behave up --build --abort-on-container-exit
```

Using behave to write test cases allows your domain experts to more easily understand the tests that are being run.

- Part of the [RemotiveCar example](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/DOCS.md)
- Example features: [blink_left.feature](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/blink_left.feature) and [hazard_light.feature](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/hazard_light.feature)
- Example step implementation [example_steps.py](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/steps/example_steps.py)
- Control how to run tests: [behave.instance.yaml](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave.instance.yaml)
- Python project: [pyproject.toml](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/pyproject.toml)

Start topology and run tests:

```bash
remotive topology build ...
docker compose -f ... --profile behave up --abort-on-container-exit
```

Optionally first start topology and then run tests (useful when writing tests)

```bash
# build and start
remotive topology build ...
docker compose -f ... up
# run tests in separate shell (dont forget --build)
docker compose -f ... up behave --build
```

Example with `hello_world` instance:

```bash
remotive topology build -f instances/hello_world/main.instance.yaml build
docker compose -f build/remotive_car_hello_world/docker-compose.yml --profile behave up --abort-on-container-exit --build
```

Notice:
- Tests are run in a container as part of the topology.
- By using a profile you can use the same instance and use the profile to control if the tests should run or not.
- In this example the same Dockerfile is used for all python code in order to reuse the same base image. You can of course use separate Dockerfile for each container.

## Where it lives in the repo

- [tests/behave/features/steps/example_steps.py](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/steps/example_steps.py)
- [tests/behave/features/blink_left.feature](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/blink_left.feature)
- [tests/behave/features/hazard_light.feature](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave/features/hazard_light.feature)
- [tests/behave.instance.yaml](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/tests/behave.instance.yaml)

[Read this use case on GitHub](https://github.com/remotivelabs/remotivelabs-remotive-car/blob/v0.9.0/usecases/TESTCASES_BEHAVE.md)

## Works well with

- [Test cases with pytest](https://developer.remotivelabs.com/docs/get-started/examples/pytest.md): Integration tests as Python code, run as part of the topology
- [Traceability with Sphinx-Needs](https://developer.remotivelabs.com/docs/get-started/examples/traceability.md): Requirements traced to ECUs, models and tests, as docs-as-code
