Spoon for testing multiple Android devices and result reporting -> awesome

I have been trying out the Espresso API for Android testing. It did not take too long to set up and run first tests. Still investigating. I will post some notes and comments later.

While trying out Espresso I found in one of Google’s forums mention of Spoon, so naturally, I decided to give it a try. As the first paragraph on the web site states (copy/paste):

Android’s ever-expanding ecosystem of devices creates a unique challenge to testing applications. Spoon aims to simplify this task by distributing instrumentation test execution and displaying the results in a meaningful way.

Here is how I tried it out.

  • I already had a simple Espresso test project that would open my app, click on a few buttons and then verify some text
  • Downloaded spoon-client-1.1.0.jar and placed it in my /libs folder for the Espresso test project.
  • Imported Spoon :
    import com.squareup.spoon.Spoon;
  • Per instructions from the web site surrounded one of my test cases with the screenshot activity
    Spoon.screenshot(activity, "initial_state");
    /* Normal test code... */
    Spoon.screenshot(activity, "after_login");
  • Built the Espresso test project.
  • Downloaded spoon-runner-1.1.0-jar-with-dependencies.jar
  • Hooked up several Android devices to my computer. Checked that adb recognized all
    adb devices
  • Executed the test :
    java -jar spoon-runner-1.1.0-jar-with-dependencies.jar --apk /path/to/my_amazing_app.apk --test-apk /path/to/EspressoTest_for_my_amazing_app.apk
  • Tests ran successfully.
  • Now accessed the /spoon-output/ folder from the location where I executed the test. Viewed the /spoon-output/index.html file. The beautiful summary appeared there. Clicking on the various device results provided more information including the screenshots. They can be viewed as animated gifs to show you the flow (whut, that’s amazing?)
  • Later created some tests that would fail and all worked rather well, the failures were in red, pass in green.
  • Not too much effort to set up but awesome benefit. I will use Spoon regularly. It is Licensed under the Apache License.