API Overview
Kensa's public API is organised around a few core concepts. Start here, then dive into the reference pages below.
Core Concepts
| Concept | What it does |
|---|---|
| Configuration | Global setup — output directory, issue tracker URL, custom renderers, and more |
| Fixtures | Type-safe, lazily-created test data shared across given, whenever, and then |
| Factory Fixtures | Parameterised @Fixture factory functions rewritten by the compiler plugin |
| Captured Outputs | Store and retrieve values produced during the action under test |
| Annotations | Control what appears in the HTML report — rendered values, notes, issues, and more |
| Async Assertions | thenEventually / thenContinually — polling assertions for asynchronous behaviour |
| Attachments | Attach arbitrary typed values to a test invocation for custom tabs |
| Sentence Hints | Comment-based hints that reshape how a statement renders in the report |
| Interaction Renderers | Custom renderers for values exchanged between actors in sequence diagrams |
| Log Tabs | Pull container/service logs into per-test report tabs |
DSL at a Glance
Every framework integration exposes the same setup/action DSL via its KensaTest; the assertion side comes from the mixin you choose:
| Method | Provided by | Context type | Purpose |
|---|---|---|---|
given(action) / and(action) | KensaTest | Action<GivensContext> | Set up test state; chain additional setup steps |
whenever(action) (alias `when`) | KensaTest | Action<ActionContext> | Exercise the system under test |
then(collector, matcher) | assertion mixin | StateCollector<T> | Assert on extracted state |
then(collector) { block } / and(...) | assertion mixin | StateCollector<T> | Assert using a lambda block; chain further assertions |
thenEventually(...) / thenContinually(...) | assertion mixin | StateCollector<T> | Poll the collector until the assertion passes (or keeps passing) within a timeout |
Framework Integration
| Framework | Artifact | Registration |
|---|---|---|
| JUnit 5 | kensa-framework-junit5 | Implement the dev.kensa.junit.KensaTest interface — extension and lifecycle listener register automatically |
| JUnit 6 | kensa-framework-junit6 | As JUnit 5 |
| Kotest | kensa-framework-kotest | Extend the dev.kensa.kotest.KensaTest base class; add KensaKotestListener in ProjectConfig |
| TestNG | kensa-framework-testng | Implement the dev.kensa.testng.KensaTest interface — listener auto-discovered via ServiceLoader |
Assertion Library Mixins
Mix one or more interfaces alongside KensaTest to gain assertion methods:
| Interface | Library |
|---|---|
WithKotest | Kotest matchers |
WithAssertJ | AssertJ |
WithHamcrest | Hamcrest (Java) |
WithHamkrest | HamKrest (Kotlin) |