How do I configure Robolectric tests? Doing this d...
# kotest
a
How do I configure Robolectric tests? Doing this doesn't seem to work:
Copy code
@Config(sdk = [Build.VERSION_CODES.O_MR1])
@RobolectricTest
class SomeTest : DescribeSpec({ ... })
w
Sadly if I understand correctly there’s no way to provide configuration when running Robolectric tests in Kotest
At least that was my conclusion from the last time I tried to do that
a
That's unfortunate! I managed to replace that by adding a
robolectric.properties
file, but now I'm getting this error:
Copy code
java.lang.IllegalStateException: this method should only be called by Robolectric
Which is also reported here: https://github.com/kotest/kotest/issues/1620 Did you manage to get Robolectric to work here? Is there a way around this?
w
We tried to build our own Robolectric extension (planning to contribute it back to Kotest repo) but it proved to be quite difficult to support configuration as well as Kotest features (for example isolation mode). Ultimately the issue is with JUnit5 not supporting per-test classloader (https://github.com/junit-team/junit5/issues/201) as well as with Robolectric not supporting JUnit5 (https://github.com/robolectric/robolectric/issues/3397). We decided to not write our Robolectric tests in Kotest until these two are fixed and proper, non-hacky support can be added
s
A four year old ticket wow
I looked at this once. The junit listener they use would need to be written again from scratch in kotlin
w
JUnit5 issue is in 5.8 milestone, which is the next bigger release. Hopefully they’ll be able to implement it, and Robolectric will follow
s
Ok junit5 will be good