Best test framework for Kotlin


There are at least three test frameworks with specific Kotlin support, and I wonder which one to choose:

Spek - “A Kotlin Specification Framework for the JVM”

  • Though Spek is not an official JetBrains project, it is hosted on the JetBrains GitHub account and has contributors from JetBrains.
  • 814 GitHub stars

KotlinTest - “Kotlin test framework based on the excellent Scalatest”

  • 471 GitHub stars

JUnit + HamKrest - “Hamcrest for Kotlin”

  • While there is no Kotlin-specific version of JUnit itself, there is HamKrest.
  • It appears to me that the Kotlin standard library is tested with JUnit.
  • 142 GitHub stars (HamKrest)

All these options and also TestNG are approved of in the book Kotlin in Action.

So I wonder which of these frameworks I should pick for a new Kotlin project - Spek, KotlinTest or JUnit5 + HamKrest? I have experience with JUnit4 + Hamcrest in Java and I know Spek offers “BDD-style” tests. But I have no idea which of these frameworks is best/state-of-the-art, the most future-proof or the most “idiomatic” for Kotlin. Maybe the ideal framework even depends on the kind of test, e.g. unit test vs. end-to-end test?


My personal preference is Spek + AssertJ or more classical TestNG + AssertJ.


I would look at some more spicy things like parametrized tests (table-driven tests, property based tests), interceptors or grouping tests by tags and see what framework fits your needs. However, I think KotlinTest will do a really good job here.


I tried MockK library, it’s awesome, verify similar to Mockito/Powermock and IT WORKS!
In additional, the Genius (the library owner - Oleksiy Pylypenko) of this library is available for chat most of the time on and helps me a lot !
Strongly recommended if you need assert,mock,staticMock, verify, test coroutines code and much more