Skip to content

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.

AspectVitestxUnit / C#
Importimport { story } from 'executable-stories-vitest'using ExecutableStories.Xunit;
Initstory.init(task)Story.Init("scenario name");
Test functionit("name", ({ task }) => { ... })[Fact] public void TestName() { ... }
Stepsstory.given(...)Story.Given(...)
Tagsstory.init(task, { tags: ["t1"] })Story.Init("name", "t1", "t2");
Cleanup(automatic)Class must implement IDisposable; call Story.RecordAndClear() in Dispose()
ScenarioPattern
User logs in successfullyMultiple Given (And auto-conversion)
Login worksStory with tags
Login blocked for suspended userUse of But
Checkout calculates totalsMultiple Then
Bulk user creationdoc.table
API accepts JSON payloaddoc.json
Import XML invoicedoc.code
Create orderBackground and tags

For the full 32-scenario set, see the Vitest recipes.