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.