Home | History | Annotate | Download | only in SpinnerTest
      1 <p>
      2     This sample is the test application for the
      3     <a href="../../../resources/tutorials/testing/activity_test.html">Activity
      4     Testing</a> tutorial. It tests the <a href="../Spinner/index.html">Spinner</a> example
      5     application.
      6 </p>
      7 <p>
      8     The test application uses the
      9 <a href="../../../reference/android/test/ActivityInstrumentationTestCase2.html"><code>ActivityInstrumentationTestCase2</code></a>
     10     test case class,
     11     which extends both <a href="../../../reference/android/app/Instrumentation">Android instrumentation</a> and the JUnit
     12 <a href="../../../reference/junit/framework/TestCase.html"><code>TestCase</code></a>
     13     class. The test runner is <a href="../../../reference/android/test/InstrumentationTestRunner.html"><code>InstrumentationTestRunner</code></a>.
     14 </p>
     15 <p>
     16     The application shows how to set up a test application project,
     17     how to create the <a href="AndroidManifest.html"><code>AndroidManifest.xml</code></a>
     18     file for a test application, and how to set up a test case class for a test fixture. The
     19     test case class, <a href="src/com/android/example/spinner/test/SpinnerActivityTest.html"><code>SpinnerActivityTest</code></a>,
     20     contains tests that demonstrate the following Android test patterns:
     21 </p>
     22     <ul>
     23         <li>
     24             Test setup: The <code>setUp()</code> method re-initializes the state of the application under test
     25             before each test is run.
     26         </li>
     27         <li>
     28             Initial conditions: The <code>testPreconditions()</code> method demonstrates how to
     29             test that the application under test is properly initialized prior to running the
     30             test fixture.
     31         </li>
     32         <li>
     33             UI interaction: The <code>testSpinnerUI()</code> method demonstrates how to send keystrokes
     34             to the activity under test and then test the result.
     35         </li>
     36         <li>
     37             Application control using instrumentation: The <code>testStateDestroy()</code> and <code>testStatePause()</code>
     38             methods demonstrate how to use instrumentation to trigger stages in the lifecycle of the activity under test.
     39         </li>
     40     </ul>
     41 <p>
     42     The <a href="AndroidManifest.html">manifest</a> declares an <code>&lt;instrumentation&gt;</code> element
     43     that links the test application with the application under test. Specifically, the
     44     element's <code>android:name</code> attribute specifies <code>InstrumentationTestRunner</code> as the
     45     instrumentation to use. The <code>android:targetPackage</code> attribute specifies
     46     <code>com.android.example.spinner</code> as the name of the Android package that contains the
     47     application under test.
     48 </p>
     49 <img alt="The initial user interface for the Spinner sample application" style="height:230px;"
     50      src="../images/SpinnerTest1.png"/>
     51 <img alt="The JUnit view in Eclipse with ADT, showing a successful test run of SpinnerTest" style="height:230px;"
     52      src="../images/SpinnerTest2.png"/>
     53