-
Notifications
You must be signed in to change notification settings - Fork 0
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
Android Day 2: Fastlane #10
Android Day 2: Fastlane #10
Conversation
This has been an interesting afternoon. So I found two Fastlane plugins to help automate these instrumentation tests: fastlane-plugin-instrumented_tests and fastlane-plugin-automated-test-emulator-run. However, I was struggling to figure out why these weren't working. Both were throwing the same error:
In the process, I documented what commands are run under the hood when we try to run the unit and UI tests from a CI server, for both iOS and Android. On iOS, since Xcode comes with many simulators, the main challenge is passing in the right parameters in a long Finally, I figured out the reason I was getting the above error is because both plugins execute Android's command line tools from Someone did create a PR in fastlane-plugin-automated-test-emulator-run to address this issue, but it seems like the repo isn't actively maintained anymore (given that the plugin was initially created in 2016). I do want to try the person's fork since I still want to compare performance, but since I'm using GitHub Actions, I think android-emulator-runner might be my best option for the long-term. But knowing the exact commands to run will still help if I have to replicate this outside GitHub. |
After more experimentation, here's what I found. The instrumentation tests seem to work best if we delegate one device per job. I kept trying to run the tests on three devices at once and I kept getting errors similar to the following:
The problem is that Now the issue is that if I want to continue using Fastlane, I would need to pass the matrix variables so that each lane would only run the tests on a device with that specific API level. According to the docs, I can pass in an |
GitHub Actions beats Fastlane for all API levels. Looking at each step individually (for API 33):
Installing the system images, booting up the emulator, and running the UI tests take the slowest, and show the most significant performance differences between the two methods. One thing to consider is that I added the unit test step in GitHub Actions, which allowed the UI tests step to run quicker since the Gradle daemon was running and some of the tasks were already up-to-date. But that's still 2.5 minutes unaccounted for Fastlane. It might be because the compileDebugKotlin task took almost 2 minutes for Fastlane, whereas it took 2 seconds for GA. I'm not sure why. But besides that, I didn't notice any other significant differences between the two methods. But this was a nice analysis to understand the world of Android! 👍 And as a bonus, when comparing the different API versions, the most significant difference was the boot time: 1m 27s for API 29, 3m 6s for API 31, and 5m 50s for API 33. |
Hopefully this will be my last commit for this PR! 🤞 I noticed that as long as I comment out the Fastlane steps in the workflow, I can keep the manual code I used in the Fastfile for reference. |
I wrote unit tests for
RecipeRepository
andMainViewModel
using JUnit 5 (also known as Jupiter). Even though Android Studio defaults to JUnit 4, I wanted to give the newer version a shot. I had to conjure some interesting mocks to get the unit tests to work while in coroutines (Kotlin's equivalent of a thread). Alongside that, I also initialized Fastlane and wrote a workflow to automate all the testing. Unlike with iOS, the gradle test command only runs the unit tests. I had some issues testing Fastlane on my PC (plus I think the network bridge between the WSL 2 VM and my C drive is causing gradle to be even slower on the command line), so I'm going to run the workflow here to test it out.For the instrumentation tests, I have two options: use the GitHub Action like in calculators, or use the Fastlane plugin. I'm going to try the Fastlane plugin to see how that compares to the GitHub Action. I like how customizable the action is, but if this is faster, I might go with the plugin instead. But since the iOS workflows were already slow, I'm curious to see how long these workflows will take. (I also wonder if there will be any problems running on a Mac since
Gemfile.lock
has the platform set tox86_64-linux
, instead ofuniversal-darwin-21
.)