Android的构建工具1.1.0,单元测试文件夹? [英] Android build tools 1.1.0, unit test folder?
问题描述
我最近安装了谷歌最新的工具,我的Android项目:
I recently installed the latest tools from google to my android project:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.xxx"
minSdkVersion 10
targetSdkVersion 21
versionCode 200
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
...
}
release {
...
}
}
buildTypes {
release {
...
}
debug {
...
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
// ---- Tests with robolectric
testCompile 'com.google.guava:guava:14.0.1'
testCompile 'junit:junit:4.+'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'org.mockito:mockito-all:2.0.2-beta'
// ---- Tests with Espresso
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.0') {
exclude module: 'hamcrest-core'
}
androidTestCompile 'org.hamcrest:hamcrest-core:1.1'
androidTestCompile 'org.hamcrest:hamcrest-integration:1.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.1'
androidTestCompile ('com.android.support.test:testing-support-lib:0.1') {
exclude module: 'hamcrest-core'
}
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.0'
androidTestCompile('junit:junit-dep:4.10') {
exclude module: 'hamcrest-core'
}
}
凡在此之前,我曾经使用 com.github.jcandksolutions.gradle:Android的单元测试:2.1.1
来运行我在JVM robolectric测试。
至于谷歌表示,他们的新构建工具:新源文件夹认定为单元测试:源/测试/ java中,SRC / testDebug / java中,SRC / testMyFlavor / Java的等等。
但正如你可以看到下面,我的测试文件夹不被识别为一个源文件夹。它曾与 com.github.jcandksolutions.gradle:Android的单元测试:2.1.1
,但没有更多的新的构建工具:
Where before that I used to use com.github.jcandksolutions.gradle:android-unit-test:2.1.1
to run my robolectric tests in the jvm.
As google says for their new build tools: "New source folders recognized as unit tests: src/test/java, src/testDebug/java, src/testMyFlavor/java etc."
But as you can see below, my test folder isn't recognised as a source folder. It worked with com.github.jcandksolutions.gradle:android-unit-test:2.1.1
, but no more with the new build tools:
我在这里缺少什么?谢谢
What I'm missing here? Thank you
推荐答案
我找到了解决方案,这是在IDE的左上角测试工件之间切换。在此屏幕上只有Android的仪表测试可用,因为我降级我的Android工具,但工具1.1.0+,你应该可以看到不同类型的测试中获得了IDE它们识别为源文件夹。
I found the solution which is to switch between Test Artifacts in the left corner of the IDE. On this screen only "Android Instrumentation Tests" is available because I downgraded my android tools but with tools 1.1.0+ you should see different types of test to get the IDE recognize them as source folders.
这篇关于Android的构建工具1.1.0,单元测试文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!