0% found this document useful (0 votes)
10 views4 pages

Event-Based Test Framework for Android

This paper presents an event-based test automation framework for Android mobile applications, where both the test scheduler and test cases are implemented as APKs. The framework allows for the creation of complex test cases utilizing Android's internal resources and APIs, facilitating efficient testing without the need for a computer connection. A case study demonstrates the framework's capability to handle various testing scenarios, including black box and performance testing.

Uploaded by

RAVISH D K
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

Event-Based Test Framework for Android

This paper presents an event-based test automation framework for Android mobile applications, where both the test scheduler and test cases are implemented as APKs. The framework allows for the creation of complex test cases utilizing Android's internal resources and APIs, facilitating efficient testing without the need for a computer connection. A case study demonstrates the framework's capability to handle various testing scenarios, including black box and performance testing.

Uploaded by

RAVISH D K
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

An Event based Test Automation Framework for Android Mobiles

Anbunathan R1, AnirbanBasu2


1
Test Manager, and Research Scholar, Bharathiar University, Coimbatore
anbunathan.r@[Link]
2
Professor, Department of CSE, East Point College of Engineering and Technology, Bangalore 560068
abasu@[Link]

info, it generates firable events to crawl through various


Abstract – Android mobile testing is challenging as it widgets and detects crashes.
involves several applications to be tested. Currently existing In [7], Hyungkeun et al. proposed an integrated
frameworks help in creating simple test cases. Designing framework which includes several open source
complex test cases which are complex in test procedure or frameworks such as NTAF, STAF, wiki, FoneMonkey
time taking need sophisticated framework. In this paper, an
and ATAF. The idea is same test case can be re-used for
event based framework is discussed. In this approach, both
test scheduler and test cases are APKs. The effectiveness of both iPhone and Android.
this framework is studied and compared with other In [5], Lulu et al. proposed a framework which involves a
frameworks. model based activity page. It is implemented through
open source frameworks such Robotium and Monkey
Keywords – Android test, Test framework, Test runner. A crawling algorithm navigates through
automation, Complex test case. components of activity page. It also generates scripts to
run with Robotium for emulator and Monkey runner for
device.
1. INTRODUCTION In [8], Delamar et al. proposed a framework which can
perform structural testing of Android mobile applications.
Android application has 4 components A provision is given to trace data back to desktop. An
such as Activity, Content provider, Service and Broadcast instrumentation scheme helps to analyze the coverage of
receiver. A complex test case which needs internal test cases, by comparing static analysis results with
resources of Android mobile can be built as an APK. This dynamic results obtained during execution.
helps to use Android framework components to build test
case efficiently. 3. Architecture of proposed test automation
framework
In this paper, a method is proposed to build test cases in
the form of APKs. These test cases are invoked by a Test In this section, architecture and design constraints of
scheduler, which is also an APK. In this paper, the design proposed test automation framework is discussed. Test
issues faced while realizing this architecture are scheduler algorithm is illustrated with suitable State
discussed. Also the advantages of this method, comparing diagram.
with other frameworks are explained. A case study is
done to illustrate how these design constraints are 3.1 Architecture of the test framework
overcome.
Figure 1 illustrates architecture of event based test
2. Related Work automation framework. It consists of a test scheduler
This section discusses other methods that have been which invokes complex test cases. The test scheduler is
proposed for Mobile Testing. Ichiro Satoh [9] proposed a nothing but an APK which is built upon basic Android
framework to test mobiles in varying network building blocks such as Activity, Service, Content
environment. This framework introduces a mobile agent- provider and Broadcast receiver. It provides checkbox
based emulator of a mobile computing device for use with options to choose test cases and then execute test cases
target application software. It was inspired by the lack of using a button labeled as ‘Execute’. Reset button resets
methodologies available for developing context-aware the State of test cases to facilitate re-running the test
applications in mobile computing settings. It aimed to cases.
emulate the physical mobility of portable computing The test cases also APKs which can be invoked from
devices through the logical mobility of applications scheduler in a predefined sequence. The scheduler
designed to run on them. Basically this framework is monitors the execution of current test case. Once
running on a computer, so that debugging will be easy. execution of current test case is completed, next test case
In [6], Domenico et al. proposed a GUI crawling-based is selected for running automatically. There exist 3
framework to test Android mobiles. This framework different patterns of test cases as given below:
works along with Robotium framework for analyzing the
components of a running Android application. Using this
978-1-4799-6629-5/14/$31.00 2014
c IEEE 76
1. Test cases made with Activity 3.2.2 State update between Scheduler and Test case
2. Test cases made with Activity and Service There are 4 different States are defined for each test case
3. Test cases made with Activity and Async task namely NotExecuted, Started, Running and Executed as
shown in Figure 2. These States need to be shared
between Scheduler and all test cases to ensure proper start
of each test case one after other. This is achieved through
content provider of Android framework, which is nothing
but Sqlite database. Different operations such as Insert,
Update, and Query are performed with this database. The
initial State of Test case is ‘Notexecuted’. When user
clicks ‘Execute’ button, the State is updated to ‘Started’
and then Test case is invoked by Scheduler. The State is
changed to ‘Running’ by Test case at the beginning of
execution and then to ‘Executed’ at the end of the
execution by Test case. The State is changed to
‘NotExecuted’ again, when user clicks ‘Reset’ button.

Figure 1: Architecture of Test Framework

3.1.1 Test cases made with Activity


These test cases are made with Activity class such as
Activity, ListActivity and FrameActivity. They are meant
for running very short duration taking 1 or 2 minutes.

3.1.2 Test cases made with Activity and Service


These test cases are made with Activity and Service. Figure 2: States of a Testcase
These test cases are meant for running long duration
taking more than 30 minutes. Android kills applications
when extremely memory stressed condition is faced. This 3.2.3 Continuous monitoring of States
situation can be overcome using service. The States of a Testcase is monitored continuously by a
Service, started from Activity of Scheduler. As some test
3.1.3 Test cases made with Activity and Async task cases are running for long time (more than 30minutes),
These test cases are made with Activity and an Async the Service has to be declared as foreground Service. Also
task. Async task runs in background without loading UI this Service has to be invoked periodically using an alarm
thread. These test cases can invoke ‘jar’ files which are manager timer, so that it listens to notifications coming
derived from UI Automator class[4]. from Content provider updates.
3.2 Architectural aspects and design constraints 3.2.4 Continuous monitoring of States
Content observers are used by Scheduler to get
In this section architectural aspects and design notifications, whenever Content provider is updated by
constraints of proposed test framework is discussed. test cases. Content observer sets a flag, when one update
in Content provider is notified. Scheduler after reading the
3.2.1 State persistence within Scheduler update, resets this flag.
As per the Android life cycle definition, when Activity
goes to back ground, its state will be changed to Pause 3.2.5 Communication between Activity and Service
and then Stop State. When the Activity goes to Resume Broadcast receiver is the mechanism used to establish
State, the data related to Activity has to be retrieved, so communication between Activity and Service of
that Activity can continue its functionality. State Scheduler. When user selects or de-selects one Testcase in
persistence within Activity is maintained using Shared UI, message is sent from Scheduler to Service using
preference. This is achieved through Shared preference. registered receivers. Critical information such as package
For example, user selects 2 complex test cases and then names, checkbox status is sent as ‘extras’. In Service,
rotates screen from portrait to landscape, even after the these extras are extracted from Intent to update Shared
same 2 test cases are selected. preference and Content provider.

2014 International Conference on Contemporary Computing and Informatics (IC3I) 77


3.2.6 Launching a Testcase 5 Experimental results
Scheduler launches each Testcase using Intent. It updates The following test cases are developed and executed
Content provider, so that Service gets message through using this framework as a proof of concept:
receiver. 1. APK debuggable test
2. Main/Sub APK test
3.3 Scheduler algorithm 3. Language test
4. APK crash test
Scheduler algorithm is shown in Figure 3.

These test cases are briefly explained in this section.

5.1 APK debuggable test


In this test case, each APK used in Android mobile is
tested for ‘debuggable’ or not. This is required to pass
CTS (Comprehensive Test Suite) requirement that all
APKs should not be debuggable. The binary is rejected, if
any one of the APK is debuggable. This test case follows
‘only Activity’ pattern as shown in Figure 1.

5.2 Main/Sub APK test


In this test case, all APKs present in Sub binary also
should present in Main binary. The Sub binary is rejected
if some APKs missed in Main binary. This is achieved by
parsing JSON file associated with each Sub binary and
Figure 3: Scheduler algorithm then comparing with JSON file contents of Main binary.
This test case follows ‘only Activity’ pattern as shown in
3.4 UI layout Figure 1.

UI layout for Test Scheduler and associated Test cases 5.3 Language test
is shown in Figure 4. In this test case, each language supported by the device
under test is selected. And then the selected language is
checked for correctness. This test case is made using UI
Automator class provided by Android. The resultant ‘jar’
file is called from ‘doInBackground’ method.
This test case follows ‘Activity-Async task’ pattern as
shown in Figure 1.

5.4 APK crash test


In this test case, each APK is launched and then checked
whether it crashed. Each APK is launched using Intent
and package name. After launching currently running
process name is compared with package name and if there
is a mismatch, that indicates potential crash. When APKs
are launched one by one, Android kills this Activity. In
this case, foreground Service is used for launching APKs,
so that Android does n’t kill this Service, even under
severe memory stressed condition.
This test case follows ‘Activity-Service’ pattern as shown
in Figure 1.

These experiments show event based framework can be


used to make complex test cases using Android APIs.

Figure 4: UI Layout for Scheduler

78 2014 International Conference on Contemporary Computing and Informatics (IC3I)


testing etc. In the future, this work has to be elaborated to
6 Comparison with Other Methods generate complex test cases automatically by taking
In [9], emulator based testing is proposed. It is mainly scenarios as input. In the present work, it is assumed that
useful for debugging the application during initial testers know Android APIs and Android architecture to
developmental stage. But in our approach, device with build complex test cases. In future, more sophisticated
actual hardware calibration is considered for testing. frameworks need to be designed to generate APKs from
In [6], a GUI crawling algorithm which considers only scenarios, which are represented through UML diagrams.
user events is proposed. But external events such as
events from hardware sensors, chips, network, and other REFERENCES
running applications are not considered. In our approach, [1] Dustin, Garett, gauf, Implementing Automated Software
all events including user events and external events are Testing, Pearson, 2010.
handled. GUI crawling framework is useful for crash [2] Google Code. Robotium. Available at:
detection and regression testing. But proposed framework [Link] Last accessed Jun. 29,
2014.
is aimed for running complex test cases, which involve
[3] Android Developers. Monkeyrunner. Available at:
system aspects such as interaction between applications, [Link]
hardware failures, and external events. 0runner_concepts.html. Last accessed Jun. 29, 2014.
In [7], several frameworks are integrated to re-use test [4] Android Developers. UI automator. Available at:
cases across platforms such as iPhone and Android. This [Link]
can help in running simple test cases. Platform specific Last accessed Jun. 29, 2014.
test cases need advanced frameworks. In the case of [5] Lu Lu, Yulong Hong, Ying Huang, Kai Su and Yuping yan,
proposed framework, test cases are running within “Activity Page Based Functional Test Automation for Android
Android phone. There is no connectivity between Application”, IEEE Third World Congress on Software
computer and mobile phone. This framework can use all Engineering (WCSE), 2012.
aspects of Android mobiles such as Android APIs to build [6] Domenico Amalfitano, Anna Rita Fasolino and Porfirio
Tramontana, “A GUI Crawling-based technique for Android
test cases. Mobile Application Testing”, IEEE Fourth International
In [5], activity page based functional automation Conference on Software Testing, Verification and Validation
framework is proposed. It is focusing on regression Workshops, 2011.
testing, and external event handling is not considered. The [7] Hyungkeun Song, Seokmoon Ryoo and Jin Hyung Kim, “An
proposed framework uses application development Integrated Test Automation Framework for Testing on
environment to build test cases. Android APIs are used to Heterogeneous Mobile Platforms”, IEEE First ACIS
build test cases. With right permission, internal Android International Symposium on Software and Network
mobile data can be manipulated. As it don’t require Engineering, 2011.
computer environment to execute test cases, testers can [8] M. E. Delamaro, A. M. R. Vincenzi and J. C. Maldonado, A
strategy to perform coverage testing of mobile applications, In
perform testing during movement under actual network Proceedings of the 2006 international workshop on Automation
varying conditions. of software test (AST '06). ACM, New York, NY, USA, 118-
In [8], a framework is proposed to analyze coverage of 124.
test cases. An instrumentation scheme is built to get [9] I. Satoh, A testing framework for mobile computing
coverage. In proposed framework, Android inbuilt log software. IEEE Transactions on Software Engineering,
system is used. The logs are analyzed, to know the current 29(12):1112–1121, Dec. 2003.
State of the device. Android APIs are used to obtain logs,
memory status, streaming information etc.

Conclusions
In this paper, a test automation framework is proposed to
test Android mobiles. Both test scheduler and test cases
are nothing but APKs. This enables to use Android APIs
to make test cases. Complex test cases are built in the
same way as if Android applications are made. Android
application building blocks such as activity, provider,
receiver and service are used to build test cases. This
architecture enables usage of Android resources such as
events, messages, UI components, widgets, timers, RTC
for making complex test cases. These test cases are
running in Android environment, and avoiding connection
with computer through USB cable or Wi-Fi.
The case study discussed here has shown that the
proposed framework can be used for variety of testing
such as black box testing, performance testing, regression
2014 International Conference on Contemporary Computing and Informatics (IC3I) 79

Common questions

Powered by AI

The APK-based test framework for Android application testing offers several advantages. Firstly, it allows for complex test cases to be built using Android's own components (Activity, Service, etc.), making the tests more integrated and efficient . Secondly, this framework facilitates testing without requiring a computer connection, enabling tests to be conducted under actual mobile conditions . Additionally, since both the test scheduler and test cases are APKs, leveraging Android APIs provides the ability to harness Android resources effectively, such as events and messages, which enhances the ability to perform a variety of tests, including black box and performance testing . This contrasts with emulator-based methods that are mainly useful for debugging during development and do not handle external events effectively .

The use of a Service in running long-duration test cases in the proposed framework addresses challenges related to application lifecycle management and resource availability. Android applications are often subjected to lifecycle events that can terminate applications when the device faces memory constraints. By running test cases within a Service, especially a foreground Service, the framework ensures continuity of execution even under memory stress . This is crucial for long-duration tests that might run for more than 30 minutes and require stability that simple Activity-based test cases cannot offer. Additionally, the Service helps in monitoring state changes and notifications, thereby maintaining the integrity of the test case execution sequence .

The proposed framework defines three patterns for test cases: (1) Test cases made with Activity; (2) Test cases made with Activity and Service; and (3) Test cases made with Activity and Async task . Test cases using only Activity are designed for short-duration tests and are appropriate for quick checks that take 1-2 minutes, such as APK debuggable tests and Main/Sub APK tests . The Activity and Service pattern is applied for long-duration tests (over 30 minutes), benefiting from the Service's capability to continue operations under memory constraints, such as testing APK crashes where the Service prevents termination . The third pattern uses an Async task for background operations, which is suitable for scenarios involving UI automation without hindering the UI thread, like executing complex language tests .

The test scheduler in the proposed framework is an APK that orchestrates the execution of complex test cases. It uses the basic Android components such as Activity, Service, Content provider, and Broadcast receiver to invoke and manage test cases. The scheduler has interactive UI elements allowing users to select test cases for execution and provides a reset option to reinitialize their state . As test cases are also APKs, they are invoked by the scheduler sequentially. The test scheduler monitors each test case through a State update mechanism facilitated by a Content provider. It keeps track of test case statuses through four states: NotExecuted, Started, Running, and Executed . Continuous monitoring involves a Service that listens for state updates via notifications triggered by Content provider changes, ensuring that test cases are executed correctly and sequentially .

The proposed framework improves upon GUI crawling techniques by extending the scope of events considered beyond user interactions to include external events like hardware and network conditions. GUI crawling traditionally focuses on user events for regression and crash testing, often missing interactions that involve hardware and network events . The proposed framework, by using APK-based test cases and leveraging Android APIs, encompasses a broader range of events, thus providing more thorough testing capabilities that address system-level complexities like application interactions and external event handling . This enhancement allows for highly integrated and comprehensive testing scenarios that GUI crawling alone cannot achieve .

Using Android APIs within the proposed framework allows the development of complex test cases that leverage native components and capabilities of the Android platform. This includes using core Android application building blocks such as Activities, Services, Content providers, and Broadcast receivers to craft test scenarios that are deeply integrated with the system. It also allows direct access to device states, internal resources, and even user-like interactions, which can be critical for testing areas such as hardware interactions, application behavior under various conditions, and performance tests . Moreover, utilizing Android's intrinsic logging and notification systems enables comprehensive tracking and debugging, enriching the testing process by providing detailed insights into system interactions and test coverage . This direct use of native environments makes the testing robust and more in tune with real-world usage scenarios compared to frameworks reliant on simulated environments .

The proposed framework primarily focuses on testing within the Android environment by using APKs as test cases and scheduler, allowing it to exploit Android's resources and APIs fully. Unlike other frameworks that integrate multiple frameworks for cross-platform compatibility and primarily address simple test cases , the proposed framework aims to handle complex test cases specific to Android. It achieves this by fully utilizing Android's capabilities, without cross-platform dependencies, making it ideal for deep, Android-specific aspects such as internal hardware failures and interactions with Android-exclusive APIs . This approach ensures thorough and specific application testing within the Android ecosystem, rather than a generalized cross-platform solution which might compromise depth for breadth .

In the test framework, Android's Broadcast receiver serves as a communication bridge between the Activity and the Service components of the test scheduler. It processes communications, specifically when a user selects or deselects test cases in the UI. These interactions send messages from the Scheduler to the Service using registered receivers. Critical information, such as package names and checkbox statuses, are sent as 'extras' within intents managed by the Broadcast receiver . This mechanism allows the test scheduler to update important state information like Shared preferences and the Content provider, ensuring seamless coordination between various components .

The proposed Android test framework ensures state persistence using mechanisms such as Shared preferences and a Content provider. Shared preferences are used to maintain state within individual Activities, allowing for state recovery across Activity lifecycle changes, such as orientation switches . For consistency across multiple test cases, the framework employs a Content provider which acts as a centralized database (SQLite) to track the state of each test case. States like NotExecuted, Started, Running, and Executed are consistently updated to reflect the current progress, ensuring that each test case runs in sequence as intended . The use of Content observers further ensures synchronization between the Scheduler and test cases, providing notifications for any state changes, thereby maintaining execution order and consistency .

Within the proposed test framework, the content provider serves as a key element for inter-component communication by acting as a relational database using SQLite. It facilitates state management across the test scheduler and test cases, ensuring proper coordination and sequence of execution. The content provider tracks the state of each test case - NotExecuted, Started, Running, and Executed - to monitor and control progression . By enabling operations like Insert, Update, and Query, the content provider allows the scheduler and test cases to share execution status and updates efficiently, thereby facilitating continuous state monitoring. This is crucial for handling the transition of states systematically, ensuring that each component of the framework is synchronized and operates cohesively .

You might also like