Add documentation how to setup for android
Your library looks really nice! Unfortunately I could not figure out how to set it up for android projects. Could you add some documentation for that?
I have never developed for android, but I am about to do some tinkering with Quest 3 apps, so I'm curious about this too.
I would expect that it would just work, but I suppose there might be some complexity with shuttling snapshot data from the simulator back to the dev environment. Can you post some info on your setup / stacktraces?
I think the main problem is that android uses junit4 by default (and I could not figure out how to make junit-vintage work).
Apart from that, the quick start guide suggests this code:
tasks.test {
useJUnitPlatform()
environment(properties.filter { it.key == "selfie" }) // optional, see "Overwrite everything" below
inputs.files(fileTree("src/test") { // optional, improves up-to-date checking
include("**/*.ss")
})
}
However, the member test of tasks cannot be resolved.
I can get this code to compile by using tasks.withType<Test> instead, but I don't know if that is correct, and the test still fails with Could not start Gradle Test Executor 5.
There are three paths:
- use Kotest and
selfie-runner-kotestio.kotest:kotest-runner-junit4- another option is
LeoColman/kotest-android
- use JUnit5 and
mannodermaus/android-junit5 - write a JUnit4 runner for Selfie
I'm a fan of Kotest anyway, so I'll probably be using kotest-android and selfie-runner-kotest. Let me know if you try any of these and how it goes!
- Kotest is not an option I think, because it does not support robolectric (Which is very important, as it allows running android integreation tests as normal unit tests): I found this repository, but it is archived unfortunately
- This works somewhat, however, I run into trouble again when using robolectric. Robolectric requires annotating the test class with
@RunWith(RobolectricTestRunner::class)and if I do that, selfie won't work on that class anymore. - That would probably be the simplest solution from a users perspective, but probably a lot of effort to write
So it seems like I can't really use this library without getting rid of robolectric :( But thanks a lot for your comments!
Thanks for looking into these! Agreed, seems like Selfie doesn't offer a satisfactory experience for Android right now. I expect this will change soon, when we make progress on this it will get reported here.