Align JUnit's API, engine, and Gradle runner
JUnit Jupiter supplies the JUnit 5 programming model. Gradle must use the JUnit Platform, and the test runtime must include an appropriate engine. A test annotation compiling does not prove tests are being discovered.
For a Kotlin/JVM learning project, use your version catalog or compatible pinned dependencies for Jupiter and the platform launcher. Configure:
// build.gradle.kts in a Kotlin/JVM project
tasks.test {
useJUnitPlatform()
}
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
class LabelTest {
@Test
fun trimsWhitespace() {
assertEquals("Kotlin", " Kotlin ".trim())
}
}
Do not mix JUnit 4 annotations and Jupiter assumptions accidentally. Android instrumented-test integration is a separate setup, so this Gradle example is intentionally for a JVM project.
Exercise
Run the suite from Gradle and confirm the report contains this test. Make the assertion wrong and verify a failing exit status. Restore it afterward.
Check: a green build with zero discovered tests is not evidence that your behavior was verified.