[[勉強会]]

* AndroidでJunitを使用する [#da5ebbbc]

Androidでは、テストファーストのためにJunitを使用してユニットテストを作成します。テストのためには、android.testパッケージのInstrumentationTestRunnerを使用します。


** API Demosのテスト用のManifestFile [#u7b85cab]
 <!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.android.apis.tests">
 
     <!-- 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. -->    
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
 
     <!--
     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"
     -->
     <instrumentation android:name="android.test.InstrumentationTestRunner"
                      android:targetPackage="com.example.android.apis"
                      android:label="Tests for Api Demos."/>
 
 </manifest>

** Hello, UnitTest [#oc779549]

作成中

--
[[勉強会]]