Testing shared code
Testing shared code in KMP is similar to writing code in KMP: in your shared code, you will have to write platform-agnostic code. This means no third-party testing frameworks or libraries that target a specific platform, JVM, JS, or iOS, such as XCTest or JUnit. Thankfully, KMP already provides a library that targets JVM, JS, and Native: https://kotlinlang.org/api/latest/kotlin.test/.
kotlin.test provides an
Asserter abstraction with a
DefaultAsserter that is dependency-free, but it also provides
TestNGAsserter so that you can choose the one you'd like to use in your JVM or Android targets.
But what about which test double (https://en.wikipedia.org/wiki/Test_double) you should choose to test your shared code – Stubs, Mocks, Spies, Fakes, or Dummies...