我正在嘗試Intellij 16 EAP,我無法正確導入其中的一個Android項目。該robolectric測試不確認爲項目Intellij 16 - 單元測試未被識別爲Android模塊項目的一部分
我進口的項目是可以在github上找到一個樣本項目的一部分:
https://github.com/robolectric/deckard
這是構建。 gradle文件:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
repositories {
jcenter()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 18
targetSdkVersion 23
versionCode 2
versionName "1.0.0-SNAPSHOT"
applicationId "com.example"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
// Support v4
compile 'com.android.support:support-v4:23.1.1'
// Espresso
androidTestCompile 'com.android.support:support-annotations:23.1.1'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
// Robolectric
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.apache.maven:maven-ant-tasks:2.1.3' // fixes issue on linux/mac
testCompile 'org.robolectric:robolectric:3.0'
}
爲什麼會發生這種情況的任何線索? 1)如果我從gradle中刪除所有android插件,並且只添加java插件,則立即識別單元測試並將它們添加到項目中。然後,只要我切換回android插件,intellij再次刪除它。 2)我試過Intellij 15和Android Studio 2.0,我得到的結果相同
你爲什麼不使用Android Studio?最新版本的AS完全支持單元測試。 – EJK
這是一個具有其他要求的大型多模塊項目。比如java spring爲其他模塊。 Intellij ultimate只是android studio的大哥哥,但總是比android功能落後2個月。與android工作室相比,java工具在intellij後面延遲了兩個月。 –