I have the following dependencies :
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2') {
// Necessary if your app targets Marshmallow (since Espresso
hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:runner:0.3') {
// Necessary if your app targets Marshmallow (since the test runner
hasn't moved to Marshmallow yet)
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile('com.android.support.test:rules:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
//ui automator test dependency
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestCompile 'com.squareup.spoon:spoon-client:1.6.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
androidTestCompile 'com.android.support:support-annotations:25.3.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4.1'
androidTestCompile('junit:junit:4.10') {
exclude module: 'hamcrest-core'
}
androidTestCompile 'org.hamcrest:hamcrest-all:1.3'
but when I import test packagesIi get test as Cannot Resolve Symbol test error.
import android.support. test .InstrumentationRegistry;
import android.support. test .espresso.ViewInteraction;
import android.support. test .filters.SdkSuppress;
import android.support. test .rule.ActivityTestRule;
Is there any solution to this? Thanks in advance.
This is my dependencies for testing, try it
//Test
dependencies{
androidTestCompile 'junit:junit:4.12'
androidTestCompile "com.android.support.test:runner:$testRulesVersion"
androidTestCompile "com.android.support.test:rules:$testRulesVersion"
androidTestCompile("com.android.support.test.espresso:espresso-
core:$espressoVersion", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile "com.android.support.test.espresso:espresso-
intents:$espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-
web:$espressoVersion"
}
with versions
ext {
testRulesVersion = '0.5'
espressoVersion = '2.2.2'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.