【问题标题】:issue with importing android.support.test.*导入 android.support.test.* 的问题
【发布时间】:2015-06-23 06:53:04
【问题描述】:

我将此依赖项添加到gradle:

// 单元测试依赖项

testCompile 'junit:junit:4.12'

// 如果要使用 Hamcrest 匹配器库,请设置此依赖项

testCompile 'org.hamcrest:hamcrest-library:1.3'

// 更多的东西,例如,Mockito

androidTestCompile 'org.mockito:mockito-core:1.+'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"

androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'

// 添加这个以支持意图模拟

androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'

// 添加这个以支持 webview 测试

 androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2'

并成功同步 build.gradle 但是当我想导入这些类时:

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

IDE (Android Studio 1.2) 给我一个无法解析符号测试的错误,我搜索太多但没有找到任何答案

【问题讨论】:

    标签: java android android-espresso


    【解决方案1】:

    我发现我的问题是什么,在 AndroidStudio 中转到文件/设置/编译器并取消选中 Use-in-process build 然后测试将起作用

    【讨论】:

    • Android Studio 1.4 Preview 3中没有这个选项
    • 它回到了 1.5,但对我没有帮助
    猜你喜欢
    • 1970-01-01
    • 2016-08-28
    • 2016-10-18
    • 2015-05-26
    • 2021-11-02
    • 2021-06-30
    • 2014-01-30
    • 2018-11-14
    • 2017-07-22
    相关资源
    最近更新 更多