behavex

raw JSON →
4.6.0 verified Mon Apr 27 auth: no python

An agile testing framework built on top of Behave (BDD) that extends functionality for parameterized scenarios and data-driven testing. Current version 4.6.0, supports Python >=3.5. Release cadence is irregular.

pip install behavex
error ModuleNotFoundError: No module named 'behavex'
cause behavex is not installed.
fix
pip install behavex
error AttributeError: module 'behave' has no attribute 'use_step_behavex'
cause Using a behavex-specific feature that is not available or changed in the current version.
fix
Update to latest behavex or check documentation for correct usage.
error behavex: error: unrecognized arguments: --behavex-param
cause Command-line parameter has changed or not supported in that version.
fix
Use --params or check behavex --help for correct options.
breaking behavex 4.x may have breaking changes from 3.x. The API for parameterized scenarios changed; check the release notes.
fix Review changelog at https://github.com/behavex/behavex/releases before upgrading.
deprecated Some older behavex-specific step decorators (like @behavex.step) have been deprecated in favor of standard behave decorators.
fix Use @given, @when, @then from `behave` module instead of behavex-specific decorators.
gotcha behavex extends behave but does not replace it. You must still install `behave` as a dependency.
fix Ensure `behave` is in your requirements.txt or installed alongside behavex.

Shows basic behavex test structure using behave syntax. Behavex extends behave with parameterized scenarios; run tests with the `behave` command.

import behavex

# behavex is an extension of behave; it uses same Gherkin syntax
# Example: feature file 'steps/example.feature'
# Feature: Example
#   Scenario: Test addition
#     Given I have 5 and 3
#     When I add them
#     Then the result should be 8

# Steps definition (in steps/example_steps.py)
from behave import given, when, then

@given('I have {a:d} and {b:d}')
def step_impl(context, a, b):
    context.a = a
    context.b = b

@when('I add them')
def step_impl(context):
    context.result = context.a + context.b

@then('the result should be {expected:d}')
def step_impl(context, expected):
    assert context.result == expected, f"Got {context.result}"

# Run with: behave