A dead-simple end-to-end testing tool for containerized microservices and monoliths, based on the Python Behave library.
Project description
BehaveDock
E2E testing for people who'd rather write tests than YAML.
BehaveDock is a Python framework for end-to-end testing that gets out of your way. Define your dependencies once, swap implementations per environment, and let dependency injection do the wiring.
Built on top of Behave and testcontainers.
Why?
E2E testing usually means:
- Writing a bunch of Docker Compose files
- Bash scripts to wait for services
- More bash scripts to seed data
- Even more scripts to tear everything down
- Tests that break when someone changes a port number
BehaveDock flips this around. You declare what your tests need to work (a database, a message broker, your microservices), implement how to provide it (Docker, staging, mocks), and the framework handles the rest.
Same tests. Different environments. No YAML required.
Install
pip install behave-dock
Quick Start
# 1. Define what you need (blueprint)
class DatabaseBlueprint(ProviderBlueprint, abc.ABC):
@abc.abstractmethod
def execute_query(self, query: str) -> list[dict]: ...
# 2. Implement how to provide it (provider)
class PostgresDockerProvider(DockerContainerProvider, DatabaseBlueprint):
def _get_container_definition(self) -> PostgresContainer:
return PostgresContainer("postgres:15")
def execute_query(self, query: str) -> list[dict]:
# ... actual implementation
# 3. Create a test interface (adapter)
class MyAdapter(Adapter):
key = "app"
database: DatabaseBlueprint # <- injected automatically
def create_user(self, name: str) -> None:
self.database.execute_query(f"INSERT INTO users ...")
# 4. Wire it up (environment + sandbox)
class MyEnvironment(Environment):
def get_blueprint_to_provider_map(self) -> dict[type, ProviderBlueprint]:
return {DatabaseBlueprint: PostgresDockerProvider()}
class MySandbox(Sandbox):
environment = MyEnvironment()
adapter_classes = [MyAdapter()]
# 5. Use in Behave
def before_all(context) -> None:
use_fixture(behave_dock, context, sandbox=MySandbox)
# 6. Write tests
@given("a user exists")
def step_impl(context) -> None:
context.sandbox.adapters["app"].create_user("alice")
Features
- Blueprints — Abstract interfaces for your dependencies
- Providers — Concrete implementations (Docker, mocks, staging)
- Adapters — Test interfaces your step definitions actually use
- Dependency Injection — Declare dependencies as type hints, get them injected
- Lifecycle Management — Setup and teardown handled automatically
- Built-in Providers — Kafka, PostgreSQL, Redis, RabbitMQ, Schema Registry
Built-in Components
Blueprints
KafkaProviderBlueprintPostgresqlProviderBlueprintRedisProviderBlueprintRabbitMQProviderBlueprintSchemaRegistryProviderBlueprint
Docker Providers
KafkaDockerProviderPostgresqlDockerProviderRedisDockerProviderRabbitMQDockerProviderSchemaRegistryDockerProvider
Adapters
KafkaAdapter— Produce messages to KafkaAPIAdapter— HTTP requests with session management
Examples
Check out the examples/ directory for a complete tutorial building a Todo app with:
- Custom blueprints and providers
- SQLite in-memory database
- Dependency injection between providers
- Behave integration
cd examples/todo_app
python -m behave features/
How It Works
┌─────────────────────────────────────────────────────────┐
│ Sandbox │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Environment │ │
│ │ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Blueprint │ │ Blueprint │ ... │ │
│ │ │ ↓ │ │ ↓ │ │ │
│ │ │ Provider │ │ Provider │ │ │
│ │ └─────────────┘ └─────────────┘ │ │
│ └───────────────────────────────────────────────────┘ │
│ ↓ │
│ ┌───────────────────────────────────────────────────┐ │
│ │ Adapters │ │
│ │ ┌─────────────┐ ┌─────────────┐ │ │
│ │ │ Adapter │ │ Adapter │ ... │ │
│ │ │ (injected) │ │ (injected) │ │ │
│ │ └─────────────┘ └─────────────┘ │ │
│ └───────────────────────────────────────────────────┘ │
│ ↓ │
│ Your Behave Tests │
└─────────────────────────────────────────────────────────┘
- Sandbox orchestrates everything
- Environment maps blueprints → providers
- Providers are set up in dependency order (so that each provider has access to all dependencies)
- Tests interact only with adapters
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file behave_dock-0.1.0.tar.gz.
File metadata
- Download URL: behave_dock-0.1.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4732451663bd4e07130f2b7a4fdbe7190c8dca2ebd4aabe692f7b652bbb6c13b
|
|
| MD5 |
bfcb2f0363257aeca4806df8a8ffad47
|
|
| BLAKE2b-256 |
f3a9e02cf1e3503c17c0174ec1408f92368bb05facb27b208502e6285a178673
|
Provenance
The following attestation bundles were made for behave_dock-0.1.0.tar.gz:
Publisher:
CICD.yml on HosseyNJF/behave-dock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_dock-0.1.0.tar.gz -
Subject digest:
4732451663bd4e07130f2b7a4fdbe7190c8dca2ebd4aabe692f7b652bbb6c13b - Sigstore transparency entry: 763370670
- Sigstore integration time:
-
Permalink:
HosseyNJF/behave-dock@2b25c77756e0de22f0d82e232f3a668150a41438 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HosseyNJF
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CICD.yml@2b25c77756e0de22f0d82e232f3a668150a41438 -
Trigger Event:
push
-
Statement type:
File details
Details for the file behave_dock-0.1.0-py3-none-any.whl.
File metadata
- Download URL: behave_dock-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ced129ae2be225f06f3d66bd978d4773dfc5f617e550a682523cf05ac54365a
|
|
| MD5 |
135bd6628b5138e1a0af62816fa3fd06
|
|
| BLAKE2b-256 |
012ea614dbc0c557b3aefd8f06ed5f00c7f155d726875fbb68a8e8b31d0e59aa
|
Provenance
The following attestation bundles were made for behave_dock-0.1.0-py3-none-any.whl:
Publisher:
CICD.yml on HosseyNJF/behave-dock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
behave_dock-0.1.0-py3-none-any.whl -
Subject digest:
6ced129ae2be225f06f3d66bd978d4773dfc5f617e550a682523cf05ac54365a - Sigstore transparency entry: 763370672
- Sigstore integration time:
-
Permalink:
HosseyNJF/behave-dock@2b25c77756e0de22f0d82e232f3a668150a41438 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/HosseyNJF
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
CICD.yml@2b25c77756e0de22f0d82e232f3a668150a41438 -
Trigger Event:
push
-
Statement type: