LoginSignup
2
2

More than 5 years have passed since last update.

Espresso 2.0 導入

Posted at

Espresso 2.0 導入時に警告が出たのでメモ

開発環境

  • AndroidStudio 2.0 Preview 4

Espresso の設定(Setup Espresso)

1. build.gradle に対して以下の依存関係を記述する
build.gradle
dependencies {
    androidTestCompile 'com.android.support:support-annotations:23.0.1'
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
    // Set this dependency if you want to use Hamcrest matching
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
}

※ com.android.support:support-annotations の警告が出ることがある
Warning:Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app and test app differ.

依存関係を修正する

build.gradle
    androidTestCompile 'com.android.support:support-annotations:23.0.1'
    androidTestCompile ('com.android.support.test:runner:0.4.1') {
      exclude module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test:rules:0.4.1') {
      exclude module: 'support-annotations'
    }
    androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
      exclude module: 'support-annotations'
    }
    // Set this dependency if you want to use Hamcrest matching
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3'

Espresso 実行(Run Espresso Tests on a Device or Emulator)

1. build.gradle の defaultConfig に testInstrumentationRunner を指定する
build.gradle
android {
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}
2. コマンドラインから実行する

./gradlew cAT

Espresso 2.0 参考

Testing UI for a Single App

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2