Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Points to remember while testing android application

What are different points to note down while testing android applications? What are different techniques or test cases used for android?

like image 785
krunal shah Avatar asked Oct 02 '10 08:10

krunal shah


People also ask

What is Android testing strategy?

Best practices in Android TestingApplication developers should create the test cases at the same time when they are writing the code. All test cases should be stored in version control-together with source code. Use continuous integration and run tests every time the code is changed.


1 Answers

Good question. Here's some lists of things to consider, with links to tools that can help.

As for implementating tests, you can read some of the tutorials listed and use frameworks like Robotium to simplify the writing of tests.

Test types

Here is a non-exhaustive list of the types of tests that should be relevant for testing an Android application.

  • Unit tests
    • Non-Android specific, i.e. business logic
    • Android unit tests, e.g. testing UI components
  • Functional tests
    • Android instrumentation tests
  • Integration tests
    • Testing the interaction of app components
  • System tests
    • Black-box testing that tests the whole app and its dependencies
  • Accesibility tests
    • Do UI components have the correct labels, descriptions and hint texts included?
    • Are there any potential problems that could affect people, e.g. colour blindness?
  • Security and reliability tests
    • Are inputs validated before use, e.g. in a local database, or before sending to a server?
    • Does the UI reliably handle all events, e.g. config changes, hardware events?

It depends on what exactly your application does, but it should be possible to test much of this automatically using some of the tools listed below.

Variables

Software and hardware features differ between the various Android devices.
You should test taking into account these, in conjunction with the types of devices your target market will be using.

  • OS version
  • Screen density
  • Screen resolution (small, normal phones, large [tablets])
  • Locale

Important is to make sure you support multiple screen types, particularly making sure you provide the right resources to support devices with different screen densities and physical screen sizes.

In general, you want to include as few graphics as possible, but make use of the various Android Drawable types, which often let you define the graphics you need via XML. Also make good use of layouts and images that automatically scale themselves no matter what device they're being used on.

Doing so will make testing across different devices simpler.

Tools

Writing tests

  • Integrated JUnit support for unit testing
  • TestCase classes for testing Android components
  • Robotium — a library that makes it very simple to write black-box functional tests that can also cross multiple activities

Using mocks

Although Android provides a few mock objects that can be used to fake components for test purposes, many more would be useful.

For this reason (and in general), designing your application with testability in mind is a good idea. For example, don't directly access ConnectivityManager, but instead create an interface that defines the method calls you need. Then write two implementations of that interface: one that wraps the Android ConnectivityManager and another, mock version. Choose the implementation you want to use at runtime, depending on whether you're running unit tests or not.

Running tests

  • InstrumentationTestRunner — the default utility for running automated Android tests
  • Android Emulator Plugin for Jenkins — automates the creation and execution of Android emulators with various configurations, so you can test one APK across multiple device types very easily
  • monkey — sends random commands to your app; a form of fuzzing

Other

  • Integrated EMMA support for measuring code coverage

Reference

Beyond all the links above, here are a few specific articles available:

  • Activity Testing Tutorial — Android's quick overview of setting up a test project, writing and running tests
  • Testing and Instrumentation — Android's overview of the test APIs and troubleshooting tips
  • Activity Testing — Further information from Android on writing and running Activity tests
like image 145
Christopher Orr Avatar answered Oct 23 '22 10:10

Christopher Orr