我已经做了一堆电子设备的测试。我想添加最近引入的Espresso 2.0。
机器人电气引入了deckard-gradle template project来解决机器人电气和意式咖啡一起使用的问题。但是解决方案是Espresso 1.1,它现在已经被弃用了。
这是我的build.gradle文件的一部分,目的是为了使用Espresso2.0,同时我也有Roboelectric以及跟随Espresso 2.0 instruction
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'org.robolectric:robolectric-gradle-plugin:0.13.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'robolectric'
android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
versionCode 1
versionName '1.0'
minSdkVersion 9
targetSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
robolectric {
include '**/*Test.class'
exclude '**/espresso/**/*.class'
}
dependencies {
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile('junit:junit:4.11') {
exclude module: 'hamcrest-core'
}
androidTestCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'plexus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-v4'
}
}但是我不能单独运行Roboelectric和Espresso测试。我很感谢你的建议。
附录:
to run roboelectric test : gradlew test
to run espresso: gradlew connectedAndroidTest发布于 2015-01-31 00:41:20
试试这个android starter项目:https://github.com/freezy/android-seed
它有很多features
在安卓Studio
,适用于functional testing)
发布于 2015-02-18 03:01:09
我排除了用来完成你想要的测试。
sourceSets {
androidTest {
java {
exclude 'com/company/project/**/*Test.java'
}
}
}和
gradle.taskGraph.whenReady {taskGraph ->
def testRunTask = project.tasks.getByName 'testDebug'
testRunTask.include(['**/*Test.class'])
testRunTask.exclude(['**/espresso/**/*.class','**/integration/**/*.class'])
}https://stackoverflow.com/questions/28066216
复制相似问题