How do I write tests? Do you use <https://kotlinla...
# getting-started
r
How do I write tests? Do you use https://kotlinlang.org/api/latest/kotlin.test/ ? There's no doc linked form there? 🤔
a
https://kotest.io is popular. The author @sam is a mod here.
1
👋🏻 1
h
Or normal annotated tests (with uses junit on the jvm):
Copy code
class Testing {
  @kotlin.test.Test
  fun testing() {
    kotlin.test.assertEquals(1, 1)
  }
}
But yes, the docs should contain a sample 😄
r
What do I need to add in terms of dependency for
import kotlin.test.*
to work?
h
implementation(kotlin("test")) in commonTest or testImplementation(kotlin("test-junit")) on jvm only projects
k
This is a helpful guide, albeit a bit dated: https://resources.jetbrains.com/storage/products/kotlinconf2018/slides/4_Best%20Practices%20for%20Unit%20Testing%20in%20Kotlin.pdf My current personal choices are: • Framework: JUnit 5. Because it seems more mature than kotlin.test (for example, unless I'm mistaken, kotlin.test doesn't have parameterized tests yet) • Mocking: MockK (when used in Kotlin, it's nicer than Mockito) • Assertions: Kotest (although I may be persuaded by AssertK) • Property-based testing: jqwik-kotlin