Book Image

Learning Android Application Testing

Book Image

Learning Android Application Testing

Overview of this book

Table of Contents (16 chapters)
Learning Android Application Testing
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The ActivityInstrumentationTestCase2 class


The ActivityInstrumentationTestCase2 class would probably be the one you use the most to write functional Android test cases. It provides functional testing of a single Activity.

This class has access to Instrumentation and will create the Activity under test using the system infrastructure, by calling InstrumentationTestCase.launchActivity(). The Activity can then be manipulated and monitored after creation.

If you need to provide a custom Intent to start your Activity, before invoking getActivity(), you may inject an Intent with setActivityIntent(Intent intent).

This test case would be very useful to test interactions through the user interface as events can be injected to simulate user behavior.

The constructor

There is only one public non-deprecated constructor for this class, which is as follows:

ActivityInstrumentationTestCase2(Class<T> activityClass)

It should be invoked with an instance of the Activity class for the same Activity used as...