I would like to use KMM as a library for business logic which can be used on a bunch of different platforms. There will be a lot of interfaces in this logic library that need to be implemented in the application repositories. When that is the case, I like to another module for testing that can be imported into test dependencies of the applications. This is the question, how do I create a kmm submodule in the logic library or have the KMM testing library depend on logic library as a whole KMM library not just a platform specific library. I’ll try to type out a toy example
////Business logic
interface One {
fun add(a:Int, b:Int):Int
}
////Business testing module/library
interface OneTest {
fun getTestSubject(): One
@Test
fun addTest() {
val result = getTestSubject().add(1,2)
assertEquals(3, result)
}
}
//application
class OneImpl : One {
override fun add(a:Int, b:Int) = a + b
}
// application tests
class OneImplTest : OneTest {
override fun getTestSubject() = OneImpl()
}
I’ve gotten this pattern to work in jvm only kotlin and love it. I am just not sure how to declare all the dependencies on KMM, or make a KMM module inside of a KMM library. Android/jvm only submodules are quite easy you include(“:testingModule”) and declare a dependency on testImplementation project(“testingModule”)