勉強会

AndroidでJunitを使用する

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

Hello, UnitTest

作成中

テスト用のManifestFileを作る

<!-- 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="jp.hews.helloandroid.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 Hello Android"/>

</manifest>