Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bdd unittest

Unit-test generation — the TDD altitude beneath the Gherkin scenarios. Where a scenario proves the behavior end to end, the unit test pins down the fine-grained contract of the production code.

Usage: bdd unittest [OPTIONS] <COMMAND>

Commands: generate

MCP tool equivalent: unit_test_create.


bdd unittest generate

Generate a unit test from a requirement’s acceptance criteria and stage it. Each Given/When/Then criterion becomes one test case with the Given as setup, the When as the action, and the Then as the assertion.

Usage: bdd unittest generate [OPTIONS] <REQ_ID>
bdd unittest generate REQ-003
{
  "target": "src/test/java/StringCalculatorTest.java",
  "staged": true,
  "source": "template",
  "summary": "Unit test for REQ-003 with 2 cases from its acceptance criteria.",
  "nextStep": "Review with 'bdd changes show', apply with 'bdd changes commit', then 'bdd test' to see RED."
}

The target file and framework follow the detected language:

LanguageTest frameworkTypical target
JavaJUnitsrc/test/java/<Name>Test.java
JavaScriptnode test runnertest/<name>.test.js
TypeScriptnode test runner + tstest/<name>.test.ts
.NETxUnit-style via the test project<Name>Tests.cs
Rust#[test]tests/<name>_test.rs

source works exactly as in bdd steps generate: deterministic template by default, "llm" only when a model’s polished version passed validation, with the session language’s best practices pinned in the prompt. Generated assertions fail honestly until the production code exists — the point is a real RED.

An unknown requirement id fails with exit status 1.

Where it fits

bdd spec show REQ-003          # read the criteria
bdd unittest generate REQ-003  # stage the test
bdd changes commit
bdd test                       # RED at both altitudes

See also