I know unit test suites exist for Android, Blackberry, Windows Phone, etc.

I have some experience in writing unit tests in Java using JUnit, and C++ using CppUnit.

Why would one want to write a unit test for a mobile phone? For example, why not just use JUnit to test Android and BlackBerry code? Is it because both devices have device specific APIs that cannot be tested using JUnit?


Edit: Links: http://iterativo.wordpress.com/tag/blackberry-bunit-unittesting/

  • Unit testing on mobile devices? Links please, it might help potential answers. Commented May 28, 2012 at 20:37
  • Added a link to bunit testing Commented May 28, 2012 at 20:49
  • Good question. Hasn't unit testing meant for tests that isolate a unit from any dependency, even the runtime environment (mobile in your case)? Is it still "unit test" by definition?
    – dzieciou
    Commented Jun 2, 2012 at 9:18

2 Answers 2


I am not a developer of any of these platforms (only iOS), but I can think of one reason: device hardware:

  • Your tests may run on your computer with computer's performance (multicore with few gigs of ram). Most mobile devices (some already do have dual-core processors and up 2GB of ram) do not have such parameters (yet). This way unit tests may be used to find bottlenecks in low-level code of the application.
  • I am not sure about Blackberry, Android or WP, but iOS does not give access to camera device from the code when it's being run on the simulator.
  • I'm no expert as well but this is what I was thinking. Mobile devices are drastically from desktop/laptops in terms of hardware and networking, so this sounds like a good answer. Commented May 29, 2012 at 14:00
  • I am an expert, and your reasons are good guesses. Performance is so divergent (for iOS, the simulator is faster; for Android, the emulator is much slower) as to be useless for insight into real-world scenarios. We get tons of spurious "failures" that are, in reality, induced by the very slow nature of the emulator; on iOS, we would see "failures" of things to exist that didn't happen on device. Furthermore, your theory on hardware not existing is mostly correct; you can fake some of it, but if you're running 90% of your tests on device, getting the last 10% over is usually worthwhile.
    – user2136
    Commented May 29, 2012 at 20:55

Great question.

Performance is not a serious reason: performance is important, and can differ between devices, but specific performance tests and benchmarks are more effective than test suites.

We derive most of the value from plain unit tests that run in a regular environment, not a device or an emulator. We mock out the phone's library (this can be hard at times but we still find it considerably more effective).

Tests that run on the phone or in an emulator are effective when you encounter integration problems with the actual hardware or other installed software. If you don't encounter it much, the value of these tests is low. If such integration issues are prevalent in your domain, you won't be able to live without them.

  • Agree. Unit testing should be designed to isolate functional issues at the lowest possible level (individual functions/methods) so we derive the most value from unit tests during development (emulator), not necessarily on devices (although we also run unit tests as part of our complete test suite on devices also). Commented Jun 12, 2012 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.