Regression testing on Android

Having Objenesis now working on Android is forcing me to make sure it keeps working. This is a call for automated regression tests.

The original idea was to test on Cloudbees on all the supported API levels (8 to 18 as of now). Luckily there is an SDK installed in their instances. And two nice blog posts explaining how to configure it.

However, I ended up using a local VM because I had some stability issues. Random parts of the build were

Everything starts with the Android Emulator Plugin. We also need the EnvInject Plugin on Cloudbees.

Then, follow these steps:

  • Create a multi-configuration project
  • Add three user-defined axis
    •  os (android-8 android-10 android-11 android-12 android-13 android-14 android-15 android-16 android-17 android-18)
    • resolution (HVGA WXGA)
    • abi (armeabi armeabi-v7a)
Now it gets funny because you need to find a combination filter mixing these three axis to create valid configurations.
  • Combination filter: (os==~/android-1[1,2,3]/).implies(resolution=="WXGA") && (!(os==~/android-1[1,2,3]/)).implies(resolution=="HVGA") && (!(os==~/android-1[4,5,6,7,8]/)).implies(abi=="armeabi") && (os==~/android-1[4,5,6,7,8]/).implies(abi=="armeabi-v7a")
From there you might ask why I'm using android-18 instead of 4.3 as the target id. That's because it doesn't work. All other versions can be named using the Android version but not 4.3. It looks like a bug of the SDK.

Run each configuration sequentially if you're in local. You won't need it on Cloudbees since it can parallelize the build on many instances.

Then, you now to configure the emulator.
  • Check "Run an emulator during build"
  • Select "Run emulator with properties"
    • Android OS version: ${os}
    • Screen density: mdpi
    • Screen resolution: ${resolution}
    • Device locale: en_US
    • Target ABI: ${abi}
  • Check "Reset emulator state at start-up"
  • Check "Use emulator snapshots"
  • Emulator options: -no-audio -gpu off
Finally, just add your Android build using the emulator. And hopefully, everything should be alright.