-
Hi, I'm involved in a Java project that some people use ice Android. The project has an extensive unit test suite and we're looking for a way to run that existing test suite against one or more Android (api) versions, to see whether our Java code is compatible with that specific Android API version (to surface issues due to changes in our code that are incompatible with a certain Android API version) Not being will versed in Android Android myself, I'm wondering whether roboelectric would fit this usecase. Additional requirement: need to be able to run the testsuite on a CI server (we use GitHub Actions) Hoping for some insight, |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi @p-bakker ,
IMO, Robolectric could be your choice to try. Robolectric is a suite of Java library that simulate Android environment on pure JVM. You can use it to test your library with different Android API/SDK versions, like Robolectric it self does. Robolectric's shadows simulate a large suite of Android APIs with great fidelity, for example AMS, WMS, PMS, and you can trust it like other large open-source projects like Flutter, Firebase-Android-SDK, AOSP, Chromium. Also we can improve some APIs' fidelity of Robolectric if you think they can be better.
Robolectric can meet this requirement because Robolectric runs its large test suite on GitHub Actions with pure Gradle command to test every commit. You can create some sample Android [library] projects that integrate your library and Roblectric, and then run |
Beta Was this translation helpful? Give feedback.
-
@utzcoz thnx for your rapid response!
That part is not of particular interest to us, as our library doesn't use any of that, as our library is a generic Java library What we are interested in is having caught that for example Given that roboelectric runs inside the JVM, would such issues surface by throwing NoClassDefFoundError/NoSuchMethodError? |
Beta Was this translation helpful? Give feedback.
-
Robolectric can detect incompatibilities in Android API but not Java APIs. I think these days you need at least Java 9 TO run Robolectric. If you want more comprehensive compatibility tests that can check Java incompatibilities I'd recommend emulator tests. In theory there may be something you can do with custom instrumentation but it may be complex. |
Beta Was this translation helpful? Give feedback.
-
Thnx for all the (quick) responses and answers. To bad roboelectric isn't a match for us, looked like it otherwise could've been a pretty straight-forward solution to our challenge. I'll go on and look at the emulator route, although from what I've read, these have their challenges as well, especially running them in a CI environment in a performant way. Wish one could just launch a virtual VM that just has the Dalvik (or whatever it's successors are called) environment, as for our purpose we don't need a full emulated environment |
Beta Was this translation helpful? Give feedback.
Robolectric can detect incompatibilities in Android API but not Java APIs. I think these days you need at least Java 9 TO run Robolectric. If you want more comprehensive compatibility tests that can check Java incompatibilities I'd recommend emulator tests. In theory there may be something you can do with custom instrumentation but it may be complex.