radish-bdd
radish is a Behavior Driven Development tool completely written in Python. It supports all Gherkin language features and also implements unconventional BDD features such as Scenario Preconditions, Scenario Loops, Constants, and Expressions. The library is actively maintained, with the latest stable version 0.18.4 released on February 24, 2026.
Common errors
-
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
cause This error or similar `lxml` related errors (e.g., `cannot find -lz`) often indicate missing C libraries like libxml2, libxslt1-dev, or zlib1g-dev required by `lxml`, which radish-bdd uses for XML reporting. This was a known issue, especially on Linux and older Windows installations.fixOn Debian/Ubuntu: `sudo apt-get install libxml2-dev libxslt1-dev zlib1g-dev`. On other Linux distributions, use the equivalent package manager. For Windows, ensure all C++ build tools are installed or try updating `pip` and `lxml` itself: `pip install --upgrade pip lxml`. -
radish.exceptions.RadishError: No step implementation found for step 'Given I have an unimplemented step'
cause A step defined in your `.feature` file does not have a matching Python function decorated with `@given`, `@when`, or `@then` in your step definition files.fixImplement the missing step function in your `radish/steps.py` (or other step definition files). For example, for 'Given I have an unimplemented step', add `@given("I have an unimplemented step")\ndef have_unimplemented_step(step):\n pass`.
Warnings
- breaking radish-bdd officially dropped support for Python 2 in recent versions (specifically 0.18.0+). Projects migrating from very old radish versions must upgrade to Python 3.
- gotcha The `world` object provides a global context, but it is not intended for storing scenario-specific data. Using `world` for this purpose can lead to test interference and state leakage between scenarios.
- gotcha If a Gherkin step in your feature file does not have a corresponding Python step implementation, radish will raise an exception and stop the test run.
Install
-
pip install radish-bdd
Imports
- given, when, then
from radish import given, when, then
- before, after
from radish import before, after
- world
from radish import world
- main
from radish import main
Quickstart
# 1. Create a feature file (e.g., calculator.feature):
# Feature: Simple Calculator
# In order to avoid silly mistakes
# As a math enthusiast
# I want to be able to add numbers
#
# Scenario: Add two numbers
# Given I have the number 5
# And I have the number 7
# When I add them
# Then the result should be 12
# 2. Create a step implementation file (e.g., radish/steps.py):
from radish import given, when, then, world
@given("I have the number {number:g}")
def have_number(step, number):
if not hasattr(world, 'numbers'):
world.numbers = []
world.numbers.append(number)
@when("I add them")
def add_numbers(step):
world.result = sum(world.numbers)
@then("the result should be {expected_result:g}")
def check_result(step, expected_result):
assert world.result == expected_result
# 3. Run from your terminal in the directory containing 'calculator.feature':
# radish calculator.feature