https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

Alberto

03/23/2021, 3:59 PM
what’s the recommended way of handling unit tests for classes that may have different way of constructing them on Android/iOS? Example SQLDelight requires an Android Context to be passed to the AndroidSqliteDriver while it’s not used for the NativeSqliteDriver. Is it better to create separate tests for Android module and iOS module, or use the common test module and check at runtime somehow if we’re testing on Android (pass the context then) vs iOS?
j

jw

03/23/2021, 4:02 PM
You can use expect/actual for that
a

Alberto

03/23/2021, 4:31 PM
yes for the implementation, but what about for testing? would you test android/iOS using the actual declarations separately?
j

jw

03/23/2021, 4:32 PM
no. common tests and expect/actual to create the driver
a

Alberto

03/23/2021, 4:33 PM
thank you, will look into this
d

Derek Ellis

03/23/2021, 6:34 PM
Keep in mind that those tests were written to be able to test with the JS driver as well which had to be initialized in a coroutine. If you don't plan on needing to target Kotlin/JS you can simplify some of it.
2 Views