AI 146204: am: CL 146203 New .jd files, modified Pdk.mk to fix doxygen </div> bug on line 25 of *-source.html files, removed extraneous SDK examples.

Original author: mritter
  Merged from: //branches/cupcake/...

Automated import of CL 146204
This commit is contained in:
Mike Ritter
2009-04-14 13:57:14 -07:00
committed by The Android Open Source Project
parent 6e00361920
commit 843a6d8b7d
24 changed files with 148 additions and 229 deletions

View File

@@ -1,4 +1,5 @@
page.title=Instrumentation Testing
pdk.version=1.0
@jd:body
<a name="toc"/>
@@ -25,11 +26,11 @@ page.title=Instrumentation Testing
<a href="#androidTestingLocationFiles">Location of Files</a><br/>
<a href="#androidTestingContentMakefile">Contents of makefile</a><br/>
<a href="#androidTestingContentManifest">Content of Manifest</a><br/>
<a href="#androidInstrumentationTestingCreatingTestRunner">New InstrumentationTestRunner</a><br/>
<a href="#androidInstrumentationTestingCreatingTestRunner">New Instrumentation TestRunner</a><br/>
<a href="#androidInstrumentationTestingCreatingTestCase">New InstrumentationTestCase</a><br/>
<a href="#androidInstrumentationFrameworkTestCase">Exploring a Test Case</a><br/>
<a href="#androidTestingKindsofTests">Deciding Kinds of Tests to Write</a><br/></div>
<a href="#androidInstrumentationFrameworkTroubleshooting">Troubleshooting</a><br/></div>
<a href="#androidInstrumentationFrameworkTroubleshooting">Troubleshooting</a><br/></div></font></div>
<a name="androidInstrumentationFrameworkIntro"></a><h2>Introduction</h2>
@@ -318,28 +319,23 @@ include $(BUILD_PACKAGE)
<a name="androidTestingContentManifest"></a><h3>Content of Manifest</h3>
<p>Use the following example to create an <code>AndroidManifest.xml</code> file that declares the instrumentation. Specify that the framework supplied InstrumentationTestRunner targets the package of your application, allowing the tests that are run with the instrumentation to get access to all of the classes of your application without having to build the source into the test app. The name of the test application is typically the same as your target application with <code>.tests</code> appended. </p>
<p>Use the following example to create an <code>AndroidManifest.xml</code> file that declares the instrumentation. Specify that the framework supplied Instrumentation TestRunner targest the package of your application, allowing the tests that are run with the instrumentation to get access to all of the classes of your application without having to build the source into the test app. The name of the test application is typically the same as your target application with <code>.tests</code> appended. </p>
<pre>
# Add appropriate copyright banner here
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.apis.tests"&gt;
&lt;!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
&lt;application>
&lt;uses-library android:name="android.test.runner" />
&lt;/application>
package="com.android.samples.tests"&gt;
&lt;uses-permission android:name="android.permission.RUN_INSTRUMENTATION" /&gt;
&lt;!--
This declares that this app uses the instrumentation test runner targeting
the package of com.example.android.apis. To run the tests use the command:
"adb shell am instrument -w com.example.android.apis.tests/android.test.InstrumentationTestRunner"
-->
the package of com.android.samples. To run the tests use the command:
"adb shell am instrument -w com.android.samples.tests/android.test.InstrumentationTestRunner"
--&gt;
&lt;instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.android.apis"
android:label="Tests for Api Demos."/>
android:targetPackage="com.android.samples"
android:label="Tests for Api Demos."/&gt;
&lt;/manifest&gt;
</pre>
<p>&nbsp;</p>
@@ -350,7 +346,7 @@ $ adb shell am instrument -w \
</pre>
<a name="androidInstrumentationTestingCreatingTestRunner"></a><h3>New InstrumentationTestRunner</h3>
<a name="androidInstrumentationTestingCreatingTestRunner"></a><h3>New Instrumentation TestRunner</h3>
<p>Create a class that derives from this class. You must override two abstract methods; one that returns the class loader of the target package, and another that defines all of the tests within the package. For example, the snippet below displays the test runner for the framework tests.</p>
<pre class="prettify">
@@ -374,6 +370,8 @@ public class FrameworkInstrumentationTestRunner extends InstrumentationTestRunne
</pre>
<p> Next, in an appropriate <code>AndroidManifest.xml</code>, define the instrumentation for the derived class with the appropriate <code>android:targetPackage</code> set. For example, the snippet below defines the instrumentation runner for the framework tests.</p>
<pre class="prettify">
&lt;uses-permission android:name="android.permission.RUN_INSTRUMENTATION" /&gt;
&lt;instrumentation android:name="android.tests.FrameworkInstrumentationTestRunner"
android:targetPackage="com.google.android.frameworktest"
android:label="framework instrumentation test runner" /&gt;
@@ -510,5 +508,4 @@ W/ActivityManager( 469): Unable to find instrumentation info for: ComponentInfo
D/AndroidRuntime( 688): Shutting down VM
E/AndroidRuntime( 688): ERROR: thread attach failed
</pre>
<p>It's possible that the instrumentation apk isn't installed on your device or that the package name is incorrect in the Manifest file. </p>
<p>It's possible that the instrumentation apk isn't installed on your device or that the package name is incorrect in the Manifest file. </p>