Getting started¶
This guide walks you through installing behave-pool, registering the runner,
and running your first parallel test suite.
Installation¶
From PyPI¶
With ecosystem extras¶
This installs optional packages:
behave-priority— Priority-based scenario orderingbehave-modern-json-report— Modern JSON report format
From source¶
Register the runner¶
behave-pool implements Behave's ITestRunner interface. You need to register
it so Behave knows how to load it.
Option A: behave.ini¶
Create or edit behave.ini in your project root:
Option B: setup.cfg / pyproject.toml (entry point)¶
If you distribute your test suite as a package, add the entry point in your
pyproject.toml:
Option C: Command-line --runner¶
You can skip registration entirely and pass the runner inline:
Your first parallel run¶
Make sure you have a features/ directory with at least two .feature files.
What happens?¶
ParallelRunnerparses all.featurefiles infeatures/.- It creates one
WorkUnitper feature file. - It launches 4 worker processes (using
spawnstart method). - Each worker consumes work units from a shared queue.
- Results are collected and aggregated.
- A
.behave-pool-timing.jsonfile is created with observed durations.
Output example¶
Feature: Login functionality
Scenario: User logs in with valid credentials ... passed
Scenario: User logs in with invalid credentials ... passed
Feature: Checkout flow
Scenario: Add item to cart ... passed
Scenario: Complete purchase ... passed
2 features passed, 0 failed, 0 skipped
4 scenarios passed, 0 failed, 0 skipped
Choosing the number of workers¶
A good starting point is the number of CPU cores:
# Check available cores
python -c "import os; print(os.cpu_count())"
# Use that many workers
behave --runner=parallel --parallel 8 features/
Rule of thumb
Start with --parallel N where N = number of CPU cores. If features are
very fast (< 1s), fewer workers may be better due to spawn overhead. If
features are slow (I/O bound), more workers than cores can improve
throughput.
Verifying installation¶
Expected output:
Next steps¶
- Configuration — Learn about all CLI options and
behave.inisettings - Serial scenarios — Handle non-parallelizable scenarios with
@serial - LPT balancing — Optimize wall-clock time with LPT scheduling
- Examples — See complete worked examples