Skip to main content

Configuration

Kensa is configured once, before your tests run. There are two styles — a Kotlin DSL and a fluent Java-friendly builder.

Entry Points

// DSL style — preferred in Kotlin
Kensa.konfigure {
outputDir = Path("build/kensa-reports")
issueTrackerUrl = URI("https://github.com/my-org/my-repo/issues/").toURL()
}

Configuration is typically placed in a test base class, a JUnit 5 @BeforeAll, or a Kotest ProjectConfig.


Output

Builder methodDSL propertyTypeDefaultDescription
withOutputDir(path)outputDirPathsystem temp dir / kensa-outputWhere HTML reports are written
withOutputDisabled()isOutputEnabled = falseBooleantrueSuppress all report generation
withUiMode(mode)uiModeUiModeUiMode.LegacyReport template (Legacy or Modern)
withFlattenOutputPackages(bool)flattenOutputPackagesBooleanfalseSimplify package paths in output filenames
withPackageDisplayMode(mode)packageDisplayPackageDisplayHideCommonPackagesHow package names appear in the report
withPackageDisplayRoot(root)packageDisplayRootString?nullRoot package to strip when displaying package names

System properties override defaults before configuration is applied:

PropertyEffect
kensa.output.rootOverrides the output directory root
kensa.disable.outputSet to any value to disable output
Kensa.konfigure {
outputDir = Path("build/kensa-reports")
packageDisplay = PackageDisplay.HideCommonPackages
}

Issue Tracker

Annotate tests with @Issue("PROJ-123") and Kensa will link to the issue in the report. Set the base URL here:

Builder methodDSL propertyTypeDescription
withIssueTrackerUrl(url)issueTrackerUrlURLBase URL — issue keys are appended directly
Kensa.konfigure {
issueTrackerUrl = URI("https://github.com/my-org/my-repo/issues/").toURL()
}

With the above URL, @Issue("42") links to https://github.com/my-org/my-repo/issues/42.


Report Layout

Builder methodDSL propertyTypeDefaultDescription
withSectionOrder(vararg sections)sectionOrderList<Section>[Tabs, Sentences, Exception]Order of report sections
withAutoOpenTab(tab)autoOpenTabTabTab.NoneWhich tab is open by default
withAutoExpandNotes(bool)autoExpandNotesBooleanfalseExpand @Notes content automatically
withTabSize(n)tabSizeInt4Code indentation width
withSetupStrategy(strategy)setupStrategySetupStrategySetupStrategy.UngroupedHow setup interactions appear in sequence diagrams

Section values: Tabs, Sentences, Exception

Tab values: CapturedInteractions, CapturedOutputs, Givens, Parameters, SequenceDiagram, None

SetupStrategy values:

ValueEffect
UngroupedSetup interactions shown inline, not grouped
GroupedSetup interactions grouped into a labelled box
IgnoredSetup interactions hidden from the sequence diagram

Sentence Parsing

Kensa parses method names to build readable sentences. Extend the dictionary to handle domain-specific terms:

Builder methodDescription
withProtectedPhrases(vararg phrases)Prevent a multi-word phrase from being split (e.g. "credit score")
withAcronyms(vararg acronyms)Register an acronym and its meaning (e.g. Acronym("API", "Application Programming Interface"))
withKeywords(vararg keywords)Add custom BDD keywords beyond the defaults
Kensa.configure()
.withProtectedPhrases(ProtectedPhrase("credit score"))
.withAcronyms(Acronym("API", "Application Programming Interface"))

Custom Renderers

Register custom value or interaction renderers for types Kensa doesn't know how to display:

Builder methodDescription
withValueRenderer(klass, renderer)Custom ValueRenderer<T> for a specific type
withInteractionRenderer(klass, renderer)Custom InteractionRenderer<T> for sequence diagram content
withListRendererFormat(format)Override the default [a, b, c] list format
Kensa.configure()
.withValueRenderer(Money::class, MoneyRenderer())
.withListRendererFormat(ListRendererFormat(separator = " | ", prefix = "(", postfix = ")"))

// Or using the DSL extension:
Kensa.konfigure {
withRenderers {
valueRenderer<Money> { money -> "${money.currency} ${money.amount}" }
}
}

Source Locations

If you use @Sources to parse helper classes referenced in tests, tell Kensa where to find source files:

Builder methodDSL propertyTypeDescription
withSourceLocations(vararg paths)sourceLocationsList<Path>Paths to scan for .kt / .java source files
Kensa.konfigure {
sourceLocations = listOf(Path("src/test/kotlin"))
}