Introducing Kensa: BDD for Kotlin and Java Without the Gherkin Tax
If you've ever set up Cucumber on a JVM project, you know the overhead: feature files, step definitions, the glue code that ties them together, and the constant friction of keeping all three in sync as your codebase evolves. The promise — shared, readable specifications — rarely survives contact with a real team.
Kensa takes a different approach. Write your Given-When-Then tests directly in Kotlin or Java. No Gherkin. No step definitions. No separate files to maintain.
How It Works
Kensa parses your test source code at runtime, extracts the sentence structure of each test method, and substitutes actual captured values for variable names. The result is living HTML documentation generated directly from your tests — not from a separate spec file that may or may not reflect what your code actually does.
Here's a test from the Clearwave example — a fictional telecoms service that checks broadband feasibility across two supplier networks:
@Test
fun `address is serviceable by both suppliers`() {
given(bothSuppliersAreServiceable())
whenever(aFeasibilityCheckIsRequestedForTheServiceAddress())
then(theFeasibilityResult(), shouldReturnServiceableResultWith(
profileCount = 3,
fastestDownloadSpeed = fixtures[voiceDownloadSpeed],
fastestSupplier = fixtures[voiceSupplier],
))
}
The test is the specification. The report shows the test sentences with real values substituted in — fastestDownloadSpeed and fastestSupplier in the report reflect what actually ran, captured from the fixture values.
What You Get
- HTML reports with the test sentences, captured state, and a full interaction log
- Sequence diagrams auto-generated from the interactions your tests record
- Inspectable payloads — click any interaction to see the full request/response
- Framework integration — JUnit 5 & 6, Kotest, and TestNG are all supported
- Assertion library flexibility — Hamcrest, AssertJ, Kotest assertions, or HamKrest
- A Kotlin compiler plugin for
@RenderedValueand@ExpandableSentence— capture values in reports without boilerplate - An IntelliJ plugin for navigating reports from the IDE
Getting Started
Add the dependency and extend KensaTest:
// build.gradle.kts
testImplementation("dev.kensa:kensa-junit:0.6.6")
The Kotlin Quickstart walks through a complete example in a few minutes.
See It In Action
The Clearwave example repo is a self-contained project showing a more complete scenario — async order processing across multiple suppliers, with sequence diagrams auto-generated from the interaction captures. You can browse the live Kensa report to see what the output looks like.
Kensa itself is open source on GitHub. Feedback and contributions welcome.