Skip to content

Recipes (JUnit 5 / Kotlin)

8 representative recipes showing key BDD patterns with JUnit 5 and Kotlin. The generated output is identical across all frameworks — only the test code differs.

AspectVitestJUnit 5 / Kotlin
Importimport { story } from 'executable-stories-vitest'import dev.executablestories.junit5.Story
Initstory.init(task)Story.init("scenario name")
Test functionit("name", ({ task }) => { ... })@Test fun \test name`() { … }`
Stepsstory.given(...)Story.given(...)
when stepstory.when(...)Story.`when`(...) (backticks — when is a Kotlin keyword)
Tagsstory.init(task, { tags: ["t1"] })Story.init("name", "t1", "t2")
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.