Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation how to setup for android #481

Open
Inky-developer opened this issue Oct 11, 2024 · 5 comments
Open

Add documentation how to setup for android #481

Inky-developer opened this issue Oct 11, 2024 · 5 comments
Labels
enhancement New feature or request jvm

Comments

@Inky-developer
Copy link

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?

@nedtwigg
Copy link
Member

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 nedtwigg added jvm enhancement New feature or request labels Oct 11, 2024
@Inky-developer
Copy link
Author

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.

@nedtwigg
Copy link
Member

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!

@Inky-developer
Copy link
Author

  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!

@nedtwigg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jvm
Projects
None yet
Development

No branches or pull requests

2 participants