Frameworks for testing Android applications

Asked

Viewed 1,258 times

3

There is no doubt that one of the main phases of the software development process is the testing phase.

Aiming for this, being beginner in the testing area, even more for Android applications, I wonder if you use any Framework? Best practices, best types of testing for mobile applications?

1 answer

5

Recommended test types for mobile apps

Many testers have doubts about the types of tests that should be run in mobile applications. Each day the number of mobile devices increases and the mobile environment is relatively new compared to the desktop. Testing on mobile apps differs from testing on desktop apps, as the immense variety of mobile devices does not allow for a standardization of the environment. Take into account, for example, that there are numerous screen sizes and different operating systems.

We can cite 6 types of tests that are usually performed in mobile applications to ensure the quality of them:

1. Compatibility

The goal here is to ensure that the application interacts and communicates with the operating system, hardware and all types of network in a satisfactory manner. If the compatibility is not checked and attested carefully, the application may suffer from slowness, data loss or crashing. A very common problem in the compatibility issue concerns the connection to the different types of network. As mobile devices, there are different types of connections running at all times.

2. Performance

Tests in this category should focus on eliminating bottlenecks that cause application slowness or locking. In this type of test, it is necessary to create situations of stress, high loads and large number of requests for each function of the application. The code should be as light as possible when it comes to mobile devices.

3. Mobility

Here you test your app’s ability to communicate with other apps. It is very common to share information between different applications and yours should be well structured for effective communication.

4. Sync and corrections by n17t01

This type of testing is relatively new and has become necessary since we started using cloud data storage technology. We need to update the data on one device and access it from another device in the future and the data must be intact and up to date. Here we must check that there are no excessive losses of packages and forwards. That is, check even if the application can synchronize the data on the network.

5. Usability

Similar to the usability test common to desktop applications. The focus should be the user experience, the ease and possibility to perform the intended actions.

6. Functional

So important that it often focuses only on that kind of test. Here, it checks whether the application actually performs the tasks it should, as planned. Tests are done to make sure that all requirements have been implemented and work the way they should.

Obviously, there are certain types of mobile applications that require specific testing, depending on the type of features they feature. But, in general, these are the types of basic tests that must be done to ensure a good quality.

It should be remembered that these types of tests are not distinguished by device brand or operating system. They serve as a basis for testing android apps, Apple apps, java apps, windows mobile, etc.

Automation Android

Android automation is divided into two parts, according to the own Android development site:

1.Unit Tests 2.UI Testing (User Interface - Graphical Interface)

Fundamentals of Testing

Before proceeding with the explanation of Unit Test and UI Test we will know common points between the two levels of test.

Android has a framework, called the Android Testing Framework, as part of the development architecture that gives us the possibility to perform tests in different ways on the platform.

This framework has some key points:

  1. The test suites are based on Junit (version 3).

  2. The extensions of Junit for Android that has auxiliary methods for the creation of mocks and life cycle control of a component.

  3. The test suites are contained within the same project in a specific test package.

  4. SDK provides a series of tools and extensions available via Eclipse ADT or by command line.

  5. SDK also provides monkeyrunner which is a api for Python devices and also a tool via command line of stress-test sending random events to the graphical user interface.

The diagram below, taken from the page Testing Fundamentals, explains some of the process of using test on the platform:

inserir a descrição da imagem aqui

The process box (process) is the heart, containing the application itself (application package) the Instrumentationtestrunner and the Test package (location where the test scripts are).

The Test package communicates with the Instrumentationtestrunner, a support class containing all the facilities for instrumentation and component access. This communicates with the Application package to access any type of component for the interaction (and test).

Test Tools and Mokeyrunner perform externally on the application directly on the Instrumentationtestrunner.

To create tests we use the set of three items: Junit, to Instrumentation and the test class ( Test case classes) that will access the process. We can also use Mocks for this job.

Instrumentation

It’s a set of methods that control the components. We can’t control the life cycle (onCreate, onResume, onDestroy. See here the life cycle) of any component via API. It is through instrumentation that other frameworks can "chat" with components.

Unit Tests

We know that Unit Testing is important in any type of application, and Android would be no different. There are three divisions for unit testing.

Activitytesting

An Activity is something focused on the user, thus focusing on the user’s interaction with a screen. It is based on the Instrumentationtestcase class that enables instrumentation in test classes.

  1. Controlling the life cycle of an Activity;

  2. Mock;

  3. Send user actions such as typing and ringtones;

    There are three ways to test an Activity with classes:

  4. Acitivityinstrumentationtestcase2: enables test control functional within an Activity, usually with a focus on multiple activities.

  5. Activityunittestcase: enables control of a single Activity in isolation, where we can create mocks and validate their behavior in the life cycle.

  6. Singlelaunchactivitytestcase: hablita the control of a single Activity but does not enable creating mocks, since it keeps the status of Activity and its calls.

Content Provider

Content Provider manages access to data structures on the platform. Generally used to obtain internal data, such as Calendar, Notes, Contacts, among others.

In this type the focus of the test is to ensure data isolation so that no unwanted results occur or false-positive.

It uses only one class, Providertestcase2 to enable data injection through mocks. Service Testing

Services are services that run over a long period and have no graphical interface.

Through class ServiceTestCase we can control the status of the service (whether it is running or not) and ensure communication with other services or agents.

UI testing

It is another level of testing that we are more used to, and not least: testing the graphical interface (screen).

In the previous items we learned a little about unit testing and how classes are made available to help the developer test their code. But now it’s our turn: to test with user perspective.

This type of test on Android is commonly called Black Box (black box, which is one of the test types we know).

All visible components on the screen for the user need to be accessible, that is, they need to have some attributes so that a tool can find them. In most elements developers must insert a content for the attribute contentDescription (which would be like an external ID) and in the case of text boxes ( EditText) fill in the attribute hint.

To plafaforma Android features a tool called uiautomatorviewer that can analyze the components on screen and obtain accessible data (contentDescription or hint).

You can access it by typing in the command line the text:

uiautomatorviwer

or by navigating to the /tools folder, where android_sdk is the path to the folder sdk android.

The components found will later serve as the basis for writing the code for the automated script in the graphical interface of Android.

inserir a descrição da imagem aqui

Considerations

This article aimed to present aspects of automation on the Android platform to serve as the basis for other articles related to development.

It is recommended that you access and read the links contained in this article, which will give you a better view of the platform and each recommendation.

Source: Test Types for Android Applications

Test Automation with android

  • Good theory, but lacking practice (tools).

  • It’s in the answer, I edited it. The types of tests are not very different for Android applications.<br> The best known tool for unit tests in applications that use the Java language is Junit, of course there are others out there just search, but the best known and conceptually better is Junit. Something else, the SDK itself provides test tools for the Eclipse IDE, and you may also be downloading the extension Eclema to cover your codes.

  • Great, I had already voted before the issue, now it’s complete. From what I hear Eclipse will no longer be supported, know if the Google IDE supports these test frameworks?

  • 1

    All I know is that Junit is a match for Android Stúdio, I don’t know about the other tools I mentioned, but there are many other tools available for Android Stúdio such as the http://robolectric.org/ and also the http://simpligility.github.io/android-maven-plugin/.

  • 1

    Great answer, thanks for the strength friend! He already knew a little about unit testing the use of Junit, but did not have the concept of the 6 types of tests that are commonly performed on Android. Will help a lot :)

  • Good my friend, all these tests make the application more consistent. Mark the answer as correct if it helped you.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.