Created
April 10, 2014 14:55
-
-
Save AbeHaruhiko/10390864 to your computer and use it in GitHub Desktop.
AndroidでJUnit4とJUnit3.8やEspressoを併用する方法 ref: http://qiita.com/AbeHaruhiko/items/5416120c8a933f0b8147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest> | |
<!-- 下記以外は省略しています --> | |
<instrumentation | |
android:name="com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" | |
android:targetPackage="your.app.package" /> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
defaultConfig { | |
// testInstrumentationRunnerの指定を削除する。 | |
// 各flavor内で指定するため。 | |
} | |
productFlavors { | |
// JUnit4用のflavor | |
junit4Test { | |
// AndroidManifest.xmlで指定する場合は、下記設定は省略可。(junit4Test{} のみ記述) | |
testInstrumentationRunner "com.uphyca.testing.JUnit4InstrumentationTestRunner" | |
} | |
// Espresso用のflavor | |
espressoTest { | |
// AndroidManifest.xmlで指定する場合は、下記設定は省略可。(espressoTest{} のみ記述) | |
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" | |
} | |
} | |
dependencies { | |
// Espresso関連jar | |
// 参考: "https://code.google.com/p/android-test-kit/wiki/Espresso#To_use_Espresso_without_dependencies" | |
// mockitoを使う場合は、hamcrest-core、hamcrest-integrationは入れないらしい。 | |
// 参考: "http://y-anz-m.blogspot.jp/2013/11/android-ui-testing-framework-espresso.html" | |
// mockitoを使わないなら、standalone版のespresso-1.1-bundled.jarだけ下記libsに入れればOK。 | |
espressoTestCompile fileTree(dir: 'src/espressoTest/libs', include: '*.jar'); | |
espressoTestCompile 'com.google.guava:guava:14.0.1', | |
'com.squareup.dagger:dagger:1.1.0', | |
'org.hamcrest:hamcrest-core:1.1', | |
'org.hamcrest:hamcrest-integration:1.1', | |
'org.hamcrest:hamcrest-library:1.1' | |
// JUnit4, mockito 関連jar | |
junit4TestCompile ("org.mockito:mockito-core:1.9.5") | |
junit4TestCompile ("com.google.dexmaker:dexmaker-mockito:1.+") | |
junit4TestCompile ("junit:junit:4.+") | |
junit4TestCompile ("com.uphyca:android-junit4:+") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment