0Pricing
Kotlin Academy · Lesson

Writing Tests with JUnit5

Structure tests.

What is JUnit5?

JUnit5 (JUnit Jupiter) is the standard testing framework for the JVM and Kotlin. It provides annotations to mark and structure test code.

  • Tests live in src/test/kotlin
  • Each test is a function
  • The runner executes them and reports results

Adding the Dependency

Add JUnit Jupiter to your test configuration and enable the JUnit platform.

dependencies {
    testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
}

tasks.test {
    useJUnitPlatform()
}

All lessons in this course

  1. Writing Tests with JUnit5
  2. Assertions
  3. Mocking with MockK
  4. Coroutine Testing
← Back to Kotlin Academy