The Problem I hope SPOON will help solve
Despite extensive testing with one of my apps, “Your word against mine” on Google Play, I’m seeing some app crashes reported on the console that I cannot recreate to date. I want to use Spoon to help with this.
My app uses real time multiplayer and also has an AI (artificial intelligence) mode where the player can play against the AI.
I figure that if I modify the app so that instead of the AI playing against the current user of the app, the AI plays against a remote player, I can get the two AIs to play against each other.
Once I have done this, I intend to use Spoon to drive two real devices with a signed APK installation that will operate over the Google real time multiplayer ecosystem and will allow the two AIs to battle it out and hopefully I can hit upon the conditions that are causing my spurious and non repeatable crash conditions, more frequently and I can see where I’ve gone wrong.
- I need both a release certificate signed instrumented APK and a release certificate signed debug app APK to run real time multiplayer under the control of an Espresso test. If I run without signing we will not be able to sign into Play services and will not be able to communicate with the other AI player.
- I need to consider room joining criteria so that any real players of my game are not affected by me running tests. For this post, I’ll ignore this as it’s not related to the technical problem solution.
- I need to modify my app so that the AIs will play each other. Again I’ll ignore this for now for the same reason.
- I need to deploy my app on two hardware devices and run it up to play a multiplayer game at the same time. This is where Spoon comes in.
Build a Release signed Debug APK
The problem is that I need both the app APK and the test APK to be signed with the release certificate. For now the way I’m doing this is to modify my build.
Create a build type for gradle to use that will apply the release key. Follow the instructions here.
Apply that build type to my project module as below.
Build both the APP and TEST APK
Now I need to build both of my APKs.
./gradlew :android:assembleDebug ./gradlew :android:assembleAndroidTest
Install the APKs on my devices (removing any previous install if required)
adb -s device_*_id shell pm uninstall com.cil.ywam.android adb -s device_*_id shell pm uninstall com.cil.ywam.android.test
Device 1 – the instrumented APK
adb -s device_1_id install /home/ian/android-projects/master/your-word-against-mine-2/android/build/outputs/apk/debug/android-debug.apk
Device 1 – the test APK
adb -s device_1_id install /home/ian/android-projects/master/your-word-against-mine-2/android/build/outputs/apk/androidTest/debug/android-debug-androidTest.apk
Device 2 – the instrumented APK
adb -s device_2_id install /home/ian/android-projects/master/your-word-against-mine-2/android/build/outputs/apk/debug/android-debug.apk
Device 2 – the test APK
adb -s device_2_id install /home/ian/android-projects/master/your-word-against-mine-2/android/build/outputs/apk/androidTest/debug/android-debug-androidTest.apk
RUN the SPOON TEST ON BOTH DEVICES
Finally I need to run spoon on the connected devices with test I built and tweaked earlier with Espresso Run Recorder.
java -jar ~/spoon/spoon-runner-1.7.1-jar-with-dependencies.jar --apk /path/build/outputs/apk/debug/android-debug.apk --test-apk /path/android/build/outputs/apk/androidTest/debug/android-debug-androidTest.apk --sdk /path/Android/Sdk --class-name multiplayer.FakedMultiplayerSingleDeviceTest
I hope this works for you and helps you to automate your testing in a more realistic environment. If you want to try out my game, here’s the link to “Your word against mine” on Google Play.