Recipes (xUnit / C#)
8 representative recipes showing key BDD patterns with xUnit and C#. The generated output is identical across all frameworks — only the test code differs.
Key difference from Vitest
Section titled “Key difference from Vitest”| Aspect | Vitest | xUnit / C# |
|---|---|---|
| Import | import { story } from 'executable-stories-vitest' | using ExecutableStories.Xunit; |
| Init | story.init(task) | Story.Init("scenario name"); |
| Test function | it("name", ({ task }) => { ... }) | [Fact] public void TestName() { ... } |
| Steps | story.given(...) | Story.Given(...) |
| Tags | story.init(task, { tags: ["t1"] }) | Story.Init("name", "t1", "t2"); |
| Cleanup | (automatic) | Class must implement IDisposable; call Story.RecordAndClear() in Dispose() |
Recipe list
Section titled “Recipe list”| Scenario | Pattern |
|---|---|
| User logs in successfully | Multiple Given (And auto-conversion) |
| Login works | Story with tags |
| Login blocked for suspended user | Use of But |
| Checkout calculates totals | Multiple Then |
| Bulk user creation | doc.table |
| API accepts JSON payload | doc.json |
| Import XML invoice | doc.code |
| Create order | Background and tags |
For the full 32-scenario set, see the Vitest recipes.