Kensa

May 7, 2026 · View on GitHub

Latest Release GitHub Stars

Kensa is a BDD testing framework for Kotlin and Java. Write Given-When-Then tests directly in code — no Gherkin files, no step definitions. Kensa parses your test source at runtime to produce rich HTML reports and sequence diagrams.

Check out the documentation for quickstarts, API reference, and examples. See the roadmap for what's coming in v0.7 and v0.8.

Write this……get this
Kensa test written in KotlinKensa generated HTML report with sequence diagram

Features

  • Code-first BDD — Given-When-Then structure in plain Kotlin/Java; no external DSL files
  • HTML reports — generated directly from test source, always in sync with the code
  • Sequence diagrams — visualise interactions between actors captured during test execution
  • Framework support — JUnit 5 & 6, Kotest, TestNG
  • Assertion libraries — Kotest, AssertJ, Hamcrest, HamKrest

How Kensa Differs from Cucumber and JBehave

Cucumber and JBehave use Gherkin — a separate plain-text language where scenarios are written in .feature files and then mapped to test code via step definitions. This keeps non-technical stakeholders involved but introduces a permanent gap between the spec and the implementation: step glue code drifts, Gherkin files go stale, and reports reflect the spec rather than what the code actually does.

Kensa takes a different approach: tests are written entirely in Kotlin or Java, using a fluent Given-When-Then DSL. There are no feature files and no step definitions. The HTML report is generated by parsing the test source directly at runtime, so it is always an accurate reflection of the test as written.

Because everything is plain code, your IDE's refactoring tools work across the full test suite without any extra steps. Rename a method or parameter and the change propagates everywhere — including what appears in the HTML report. With Cucumber or JBehave, renaming a step definition leaves the .feature or .story files out of sync, breaking the mapping silently until the next test run.

KensaCucumber (JVM)JBehave
Test languageKotlin / JavaGherkin + Java/KotlinGherkin + Java
Step definitionsNot requiredRequiredRequired
Reports generated fromLive test source codeGherkin feature filesGherkin story files
IDE refactoring supportFull — pure code, no external filesPartial — step definitions refactor but feature files don'tPartial — step definitions refactor but story files don't
Sequence diagramsBuilt-inNot built-inNot built-in
Framework supportJUnit 5/6, Kotest, TestNGJUnit 5, TestNGJUnit, TestNG, Spring Test

Kensa is the right fit if your team writes and owns the tests in code and wants reports that stay honest to what is actually being tested.

Getting Started

Add the dependency for your test framework:

// build.gradle.kts
dependencies {
    testImplementation("dev.kensa:kensa-junit:<version>")   // JUnit 5 & 6
    // or
    testImplementation("dev.kensa:kensa-kotest:<version>")  // Kotest runner

    // Assertions bridge (pick one or more)
    testImplementation("dev.kensa:kensa-kotest:<version>")
    testImplementation("dev.kensa:kensa-assertj:<version>")
}

Find the latest version on the releases page.

See the Kotlin quickstart or Java quickstart for a full setup walkthrough.

Tooling

CLI — serve reports locally

Copy the wrapper script from cli/wrappers/ into your project root (kensa for macOS/Linux, kensa.bat for Windows) and commit it. The wrapper auto-downloads and keeps the binary up to date from GitHub releases.

kensa --dir build/kensa-output

This starts a local HTTP server and opens your HTML reports in the browser. You can also define named folders in a .kensa-properties file — see the CLI docs for details.

IntelliJ Plugin — open reports from your IDE

Install the Kensa plugin from the JetBrains Marketplace to open any Kensa report directly from IntelliJ IDEA — no hunting through the filesystem.

  • Gutter icons on test functions
  • Links in the test console output
  • Test toolbar actions

AI Agent Skills — teach your AI assistant Kensa

The kensa-dev/agent-skills repository ships a skill that teaches AI coding agents to write and review idiomatic Kensa tests. Works with Claude Code, OpenCode, and any agent that supports SKILL.md.

For Claude Code:

/plugin marketplace add kensa-dev/agent-skills
/plugin install kensa

See the AI Agent Skills docs for OpenCode, JetBrains AI Assistant, GitHub Copilot, and Cursor instructions.

Community

Questions, ideas, and feedback welcome in GitHub Discussions.