https://kotlinlang.org logo
g

Gene Cahill

03/05/2021, 5:03 PM
I am working on a multi-platform project and in my commonTest it requires Robolectric test runner (i.e. @RunWith(Robolectric::class)) when running the android actual implementation. I’d like to get the benefit of having a single test execute for both android and ios targets without adding android dependencies to commonTest. Is there a clean way to do this?
a

ankushg

03/05/2021, 5:10 PM
No experience specifically with Robolectric, but maybe you can use expect/actuals to define the annotation and class for Android and make it a no-op for iOS? Here’s an article I wrote about how I got Parcelize to work using similar techniques: https://ankushg.com/posts/multiplatform-parcelize/
g

Gene Cahill

03/05/2021, 5:23 PM
Yeah that’s exactly what I did. Was just curious if there was a more direct way