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
- Writing Tests with JUnit5
- Assertions
- Mocking with MockK
- Coroutine Testing