page.title=Testing App Component Integrations page.tags=testing,integration trainingnavtop=true startpage=true @jd:body
If your app uses components that users do not directly interact with, such as a Service or Content Provider, you should validate that these components behave in a correct way with your app.
When developing such components, you should get into the habit of writing integration tests in order to validate the component's behavior when your app runs on a device or an emulator.
Note: Android does not provide a separate test case class for {@link android.content.BroadcastReceiver}. To verify that a {@link android.content.BroadcastReceiver} responds correctly, you can test the component that sends it an {@link android.content.Intent} object. Alternatively, you can create an instance of your {@link android.content.BroadcastReceiver} by calling {@code InstrumentationRegistry.getTargetContext()}, then call the {@link android.content.BroadcastReceiver} method that you want to test (usually, this is the {@link android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent) onReceive()} method).
This class teaches you to build automated integration tests using the testing APIs and tools that the Android platform provides.