Showing posts with label bugs. Show all posts
Showing posts with label bugs. Show all posts

Wednesday, June 27, 2012

Using the Android Monkey tool

Android comes with a command-line tool (Monkey) that allows you to stress-test your application.  Monkey generates some random user events and will stop and report any errors that it encounters. It is very useful in helping to flesh out some not so obvious bugs that could be lurking in your application.  Below is an example of how we used it to test one of our applications under development.


cmd> adb shell monkey -p com.sivart.buddingbaby -v 200


Results:
:Monkey: seed=0 count=200
:AllowPackage: com.sivart.buddingbaby
:IncludeCategory: android.intent.category.LAUNCHER
:IncludeCategory: android.intent.category.MONKEY
// Event percentages:
// 0: 15.0%
// 1: 10.0%
// 2: 15.0%
// 3: 25.0%
// 4: 15.0%
// 5: 2.0%
// 6: 2.0%
// 7: 1.0%
// 8: 15.0%
:Switch: #Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10000000;component=com.sivart.buddingbaby/.SplashScreenActivity;end
// Allowing start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sivart.buddingbaby/.SplashScreenActivity } in package com.sivart.buddingbaby
:Sending Pointer ACTION_MOVE x=-4.0 y=2.0
:Sending Pointer ACTION_UP x=0.0 y=0.0
// activityResuming(com.android.launcher)
// Rejecting resume of package com.android.launcher
:Sending Pointer ACTION_DOWN x=47.0 y=496.0
:Sending Pointer ACTION_UP x=29.0 y=503.0
:Sending Pointer ACTION_DOWN x=255.0 y=143.0
:Sending Pointer ACTION_UP x=255.0 y=143.0
:Sending Pointer ACTION_DOWN x=295.0 y=659.0
:Sending Pointer ACTION_UP x=290.0 y=649.0
:Sending Pointer ACTION_MOVE x=-5.0 y=3.0
:Sending Pointer ACTION_MOVE x=0.0 y=-5.0
// Rejecting start of Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=com.android.launcher/com.android.launcher2.Launcher } in package com.android.launcher
:Sending Pointer ACTION_DOWN x=74.0 y=803.0
:Sending Pointer ACTION_UP x=74.0 y=803.0
:Sending Pointer ACTION_MOVE x=3.0 y=-2.0
:Sending Pointer ACTION_UP x=0.0 y=0.0
:Sending Pointer ACTION_MOVE x=-4.0 y=2.0
//[calendar_time:2012-06-22 22:19:07.777 system_uptime:307227]
// Sending event #100
:Sending Pointer ACTION_MOVE x=4.0 y=2.0
:Sending Pointer ACTION_DOWN x=309.0 y=694.0
:Sending Pointer ACTION_UP x=322.0 y=694.0
:Sending Pointer ACTION_MOVE x=0.0 y=-1.0
:Sending Pointer ACTION_DOWN x=294.0 y=319.0
:Sending Pointer ACTION_UP x=294.0 y=319.0
:Sending Pointer ACTION_DOWN x=118.0 y=497.0
:Sending Pointer ACTION_UP x=119.0 y=493.0
:Sending Pointer ACTION_DOWN x=137.0 y=284.0
:Sending Pointer ACTION_UP x=124.0 y=295.0
:Sending Pointer ACTION_DOWN x=258.0 y=403.0
// Rejecting start of Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity } in package android
:Sending Pointer ACTION_UP x=273.0 y=403.0
:Sending Pointer ACTION_MOVE x=-5.0 y=-5.0
// Rejecting start of Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity } in package android
Events injected: 200
Dropped: keys=0 pointers=0 trackballs=0 flips=0
## Network stats: elapsed time=6268ms (6268ms mobile, 0ms wifi, 0ms not connected)
// Monkey finished


Have you used Monkey successfully?  Leave a comment below to share your results.

Thursday, August 25, 2011

Application Crash Reporting -- Android Style

In order to provide users with an error-free as possible application, it's imperative that you use some form of Crash Reporting. The ACRA library which is available on Android provides such a framework. Here is how they describe their tool:
"ACRA is a library enabling Android Application to automatically post their crash reports to a GoogleDoc  form. It is targeted to android applications developers to help them get data from their applications when they crash or behave erroneously."

We have integrated the ACRA library into our application, Word Crank, so far I have been able to fix 3 major bugs that did not turn up in testing, but were clearly called out in the Google Doc created by the ACRA tool. We chose to go with the most basic functionality that of sending a Crash Report every time the application Force Closes. However, it is very configurable and can display status messages, custom Android Toasts, etc.

I highly recommend this tool for anyone developing an Android Application. You can download it here: ACRA Crash Reporting Tool