我已经进行了一系列Roboelectric测试.我想添加最近推出的Espresso 2.0.
Roboelectric推出了deckard-gradle template project以解决使用Roboelectric和Espresso的问题.但解决方案适用于Espresso 1.1,现已弃用.
这是我的build.gradle文件的一部分,为了使用Espresso 2.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
解决方法:
试试这个android启动项目:
https://github.com/freezy/android-seed
它有很多features:
>在Android Studio中很好地加载
> Robolectric测试在IDE中工作和调试(用于单元测试)
> Espresso测试在IDE中工作和调试(用于功能测试)
>最新的Lollipop compat libs随时可用
>启用测试覆盖范围
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。