KotlinAssertionUse¶
Issue ID KotlinAssertionUse ·
Severity Warning ·
Category Correctness ·
Default on
Flags calls to Kotlin's built-in assert(condition) (from
kotlin.PreconditionsKt) inside test sources.
Why¶
kotlin.assert only runs when the JVM is started with -ea (assertions
enabled). In a typical test run that flag isn't set, so the call quietly
becomes a no-op and the test cannot fail. Even when assertions are enabled,
the failure message is just "Assertion failed" — assertk produces
descriptive, value-aware messages.
Example¶
Quick fix¶
Yes — the IDE rewrites assert(x) to assertThat(x).isTrue() and adds
the necessary imports (assertk.assertThat, assertk.assertions.isTrue).