Dependencies 浓缩咖啡测试的正确相关性是什么?
在不同的Android官方网站上,关于如何设置浓缩咖啡测试有不同的信息: (一)Dependencies 浓缩咖啡测试的正确相关性是什么?,dependencies,android-espresso,Dependencies,Android Espresso,在不同的Android官方网站上,关于如何设置浓缩咖啡测试有不同的信息: (一) 依赖项{ //其他依赖项。。。 androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2' } (二) 依赖项{ //本地单元测试所需(JUnit4框架) testCompile'junit:junit:4.12' //仪器化测试所需 androidTestCompile'com.android.support:支持注
依赖项{
//其他依赖项。。。
androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2'
}
(二)
依赖项{
//本地单元测试所需(JUnit4框架)
testCompile'junit:junit:4.12'
//仪器化测试所需
androidTestCompile'com.android.support:支持注释:24.0.0'
androidTestCompile'com.android.support.test:runner:0.5'
}
(三)
androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2'
androidTestImplementation'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test:规则:1.0.2'
- 对于某些配置,我会遇到库冲突((2)说明这是由于依赖项需要相同的其他依赖项,但版本不同)
- 即使排除
可能没用androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2'{ 排除组:“com.android.support”,模块:“support annotations” }
- 对于某些配置,我在导入android.support.test.rule.ActivityTestRule时遇到一个错误
依赖项{
androidTestImplementation'com.android.support.test.espresso:espresso核心:3.0.2'{
排除组:“com.android.support”,模块:“support annotations”
}
androidTestImplementation'com.android.support.test:runner:1.0.2'
androidTestImplementation'com.android.support.test:规则:1.0.2'
}
似乎对于较旧的espresso版本,如
2.2.2
,android.support.test.rule.ActivityTestRule导入不需要单独的依赖项。espresso是一种仪器测试。这些测试与单元测试放在不同的文件夹中。它们保存在androidTest/java包中。所以在使用依赖项时请记住这一点。对于仪器测试,您需要使用
androidTestImplementation
vs
因此,假设您的浓缩咖啡测试类位于app->src->androidTest->java location中,这应该可以工作:
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
这是我的
build.gradle
Cucumber+Espresso+Barista的设置,可能会有人想看看这个:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.lomza.uitestsapp"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testApplicationId "com.lomza.uitestsapp.tests"
testInstrumentationRunner "com.lomza.uitestsapp.tests.GroceriesAppAndroidTestRunner"
}
sourceSets {
androidTest {
assets {
assets.srcDirs = ['src/androidTest/assets']
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "io.cucumber:cucumber-android:4.4.1"
androidTestImplementation('com.schibsted.spain:barista:3.3.0') {
exclude group: 'org.jetbrains.kotlin'
}
}
检查我的整个系统,看看它是否起作用
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.lomza.uitestsapp"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testApplicationId "com.lomza.uitestsapp.tests"
testInstrumentationRunner "com.lomza.uitestsapp.tests.GroceriesAppAndroidTestRunner"
}
sourceSets {
androidTest {
assets {
assets.srcDirs = ['src/androidTest/assets']
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "io.cucumber:cucumber-android:4.4.1"
androidTestImplementation('com.schibsted.spain:barista:3.3.0') {
exclude group: 'org.jetbrains.kotlin'
}
}