testing-bdd-for-apps

A guide to behavior-driven development (BDD), a way to describe application behavior in examples and test those examples. It uses Behave for acceptance tests and test containers for running required services during tests.

In plain words
What is it for?
Use it to organize feature files and step definitions, share data during a test scenario, and start services such as databases only when tagged tests need them.
Why use it?
It gives tests a consistent structure and manages setup and cleanup for each scenario. This reduces repeated test code and avoids tests interfering with one another.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/syntaxarc/archipy-plugin/testing-bdd-for-apps
Clone the repo
git clone --depth 1 https://github.com/SyntaxArc/archipy-plugin
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 466 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00466
Opus 5 $0.00000 $0.00233
Sonnet 5 $0.00000 $0.00093
Haiku 4.5 $0.00000 $0.00047

Measured yesterday against content hash f7a13ac539b0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-bdd-for-apps scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/testing-bdd-for-apps.mdc · 61 lines

What it actually says

BDD Testing for ArchiPy Apps

ArchiPy-style apps use Behave (not pytest) for acceptance tests.

Live: https://syntaxarc.github.io/ArchiPy/tutorials/testing_strategy/

Layout

features/
├── *.feature
├── steps/
├── scenario_context.py              # Per-scenario storage + cleanup
├── scenario_context_pool_manager.py # Singleton pool by scenario ID
├── test_helpers.py                  # get_current_scenario_context
├── environment.py                   # TestConfig + before/after hooks
└── test_containers.py               # Infra only — ContainerManager + @needs-* map

Extras: uv add "archipy[behave]"; infra also uv add "archipy[testcontainers]".

Lifecycle (environment.py)

  1. before_allTestConfig / set_global, ScenarioContextPoolManager, optional ContainerManager
  2. before_feature — start containers from @needs-* tags only
  3. before_scenario — allocate ScenarioContext from pool
  4. after_scenariocleanup_context + SessionManagerRegistry.reset()
  5. after_feature / after_allContainerManager.stop_all(), cleanup_all()

Prefer /scaffold-bdd templates over copying ArchiPy-core gRPC/Temporal hooks.

Ports and Mocks

  • Inject mocks (e.g. RedisMock) or real adapters via scenario context.
  • Never share mutable globals across scenarios.

Infrastructure Tags

@needs-redis
Feature: ...

ContainerManager.extract_containers_from_tagsstart_containers. Register only containers the app tests.

uv run behave --tags=~@needs-redis

Do Not

  • Share adapter/DB state across scenarios without cleanup.
  • Use pytest as the primary ArchiPy app test style.
  • Paste the full ArchiPy library test_containers.py catalogue into an app.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 61 lines · 466 tokens per session scan A f7a13ac539b0

Subscribe to this mod's changes

testing-bdd-for-apps is a cursor rule published in the GitHub repository SyntaxArc/archipy-plugin (2 stars, last pushed 8d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 466 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.