selfie icon indicating copy to clipboard operation
selfie copied to clipboard

Add documentation how to setup for android

Open Inky-developer opened this issue 1 year ago • 5 comments

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?

Inky-developer avatar Oct 11 '24 15:10 Inky-developer

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?

nedtwigg avatar Oct 11 '24 17:10 nedtwigg

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.

Inky-developer avatar Oct 11 '24 20:10 Inky-developer

There are three paths:

  1. use Kotest and selfie-runner-kotest
  2. use JUnit5 and mannodermaus/android-junit5
  3. 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!

nedtwigg avatar Oct 13 '24 00:10 nedtwigg

  1. 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
  2. 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.
  3. 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!

Inky-developer avatar Oct 13 '24 10:10 Inky-developer

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.

nedtwigg avatar Oct 15 '24 22:10 nedtwigg