Skip to main content

API Overview

Kensa's public API is organised around a few core concepts. Start here, then dive into the reference pages below.

Core Concepts

ConceptWhat it does
ConfigurationGlobal setup — output directory, issue tracker URL, custom renderers, and more
FixturesType-safe, lazily-created test data shared across given, whenever, and then
Factory FixturesParameterised @Fixture factory functions rewritten by the compiler plugin
Captured OutputsStore and retrieve values produced during the action under test
AnnotationsControl what appears in the HTML report — rendered values, notes, issues, and more
Async AssertionsthenEventually / thenContinually — polling assertions for asynchronous behaviour
AttachmentsAttach arbitrary typed values to a test invocation for custom tabs
Sentence HintsComment-based hints that reshape how a statement renders in the report
Interaction RenderersCustom renderers for values exchanged between actors in sequence diagrams
Log TabsPull 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:

MethodProvided byContext typePurpose
given(action) / and(action)KensaTestAction<GivensContext>Set up test state; chain additional setup steps
whenever(action) (alias `when`)KensaTestAction<ActionContext>Exercise the system under test
then(collector, matcher)assertion mixinStateCollector<T>Assert on extracted state
then(collector) { block } / and(...)assertion mixinStateCollector<T>Assert using a lambda block; chain further assertions
thenEventually(...) / thenContinually(...)assertion mixinStateCollector<T>Poll the collector until the assertion passes (or keeps passing) within a timeout

Framework Integration

FrameworkArtifactRegistration
JUnit 5kensa-framework-junit5Implement the dev.kensa.junit.KensaTest interface — extension and lifecycle listener register automatically
JUnit 6kensa-framework-junit6As JUnit 5
Kotestkensa-framework-kotestExtend the dev.kensa.kotest.KensaTest base class; add KensaKotestListener in ProjectConfig
TestNGkensa-framework-testngImplement 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:

InterfaceLibrary
WithKotestKotest matchers
WithAssertJAssertJ
WithHamcrestHamcrest (Java)
WithHamkrestHamKrest (Kotlin)