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.

Aspect Vitest JUnit 5 / Kotlin
Import import { story } from 'executable-stories-vitest' import dev.executablestories.junit5.Story
Init story.init(task) Story.init("scenario name")
Test function it("name", ({ task }) => { ... }) @Test fun \test name`() { … }`
Steps story.given(...) Story.given(...)
when step story.when(...) Story.`when`(...) (backticks — when is a Kotlin keyword)
Tags story.init(task, { tags: ["t1"] }) Story.init("name", "t1", "t2")
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.