Home | History | Annotate | Download | only in integration-testing
      1 page.title=Testing App Component Integrations
      2 page.tags=testing,integration
      3 
      4 trainingnavtop=true
      5 startpage=true
      6 
      7 @jd:body
      8 
      9 <div id="tb-wrapper">
     10 <div id="tb">
     11         <h2>
     12           You should also read
     13         </h2>
     14         <ul>
     15           <li>
     16             <a href="{@docRoot}tools/testing-support-library/index.html">Testing Support Library</a>
     17           </li>
     18         </ul>
     19 </div>
     20 </div>
     21 
     22 <p>
     23 If your app uses components that users do not directly interact with, such as
     24 a <a href="{@docRoot}guide/components/services.html">Service</a> or
     25 <a href="{@docRoot}guide/topics/providers/content-providers.html">Content Provider</a>, you
     26 should validate that these components behave in a correct way with your app.</p>
     27 <p>When developing such components, you should get into the habit of writing
     28 <em>integration tests</em> in order to validate the component's behavior when your app runs on a
     29 device or an emulator.</p>
     30 
     31 <p class="note"><strong>Note:</strong> Android does not provide a separate test case class for
     32 {@link android.content.BroadcastReceiver}. To verify that a
     33 {@link android.content.BroadcastReceiver} responds correctly, you can test the component that sends
     34 it an {@link android.content.Intent} object. Alternatively, you can create an instance of your
     35 {@link android.content.BroadcastReceiver} by calling
     36 <a href="{@docRoot}reference/android/support/test/InstrumentationRegistry.html#getContext()">
     37 {@code InstrumentationRegistry.getTargetContext()}</a>, then call the
     38 {@link android.content.BroadcastReceiver} method that you want to test (usually, this is
     39 the
     40 {@link android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
     41 onReceive()} method).</p>
     42 
     43 <p>This class teaches you to build automated integration tests using the testing APIs and tools
     44 that the Android platform provides.</p>
     45 <h2>Lessons</h2>
     46 <dl>
     47   <dt><strong><a href="service-testing.html">
     48 Testing Your Service</a></strong></dt>
     49     <dd>Learn how to build integration tests to verify that a service works correctly with your
     50     app.</dd>
     51   <dt><strong><a href="content-provider-testing.html">
     52 Testing Your Content Provider</a></strong></dt>
     53     <dd>Learn how to build integration tests to verify that a content provider works correctly with
     54     your app.</dd>
     55 </dl>