简体   繁体   English

Android Studio 2.3在UI中没有Test Instrumentation说明符

[英]Android Studio 2.3 doesn't have Test Instrumentation specifier in UI

After updating to Android Studio 2.3 when I try to run some espresso tests I get the following error: 在我尝试运行一些espresso测试后更新到Android Studio 2.3后,我收到以下错误:

Test running failed: Unable to find instrumentation info for: ComponentInfo{com.example.android/android.test.InstrumentationTestRunner} Empty test suite. 测试运行失败:无法找到以下内容的检测信息:ComponentInfo {com.example.android/android.test.InstrumentationTestRunner}空测试套件。

This was easily fixable in the past where in the Run Configuration I could specify my own InstrumentationRunner . 这在过去很容易解决,在运行配置中我可以指定我自己的InstrumentationRunner Now I can't seem to find this option so I can't really specify my runner class now. 现在我似乎无法找到这个选项,所以我现在无法真正指定我的跑步者类。

Note that my build gradle does contain 请注意,我的构建gradle确实包含

defaultConfig {
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    resConfigs "en", "es"
}

I ran into this problem this morning. 我今天早上遇到了这个问题。 I deleted the old run configuration (the one that was created before you specified the new runner via build.gradle ). 我删除了旧的运行配置(在通过build.gradle指定新运行程序之前创建的配置)。 I re-ran the tests and the new runner was picked up by Android Studio. 我重新进行了测试,Android Studio选择了新的跑步者。

On Android Studio 2.3 this feature is not available as this was an optional to specify the Instrumentation Runner package/class in previous versions of Studio. 在Android Studio 2.3上,此功能不可用,因为这是在以前版本的Studio中指定Instrumentation Runner程序包/类的可选项。 But Android 2.3 is smart enough to pick this from your build.gradle file provided you have defined Instrumentation package runner there. 但Android 2.3非常智能,可以从build.gradle文件中选择这个,只要你在那里定义了Instrumentation包运行器。

The following setup fixed the issue 以下设置修复了该问题

productFlavors {
        doTheTests {
            minSdkVersion 18
            testInstrumentationRunner "com.company.app.test.TestRunner"
            if (System.getenv('CONTINUOUS_INTEGRATION').equals("true")) {
                testInstrumentationRunnerArguments(package: "com.company.app.test")
            }
        }
    } 

Because Android Studio doesn't allow the testInstrumentationRunnerArguments but executing the tests through terminal indeed requires it! 因为Android Studio不允许testInstrumentationRunnerArguments但是通过终端执行测试确实需要它!

Obviously on the terminal / CI system, set an environment variable like: export CONTINUOUS_INTEGRATION=true 显然,在终端/ CI系统上,设置一个环境变量,如: export CONTINUOUS_INTEGRATION=true

什么对我有帮助 - 从命令行开始测试然后同步项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android Studio中运行检测测试的问题; 找不到类“ android.test.runner.AndroidJUnitRunner” - Issues with running an instrumentation test in Android Studio; Didn't find class “android.test.runner.AndroidJUnitRunner” 更新到2.3后,Android Studio不会生成签名的apk - Android Studio doesn't generate signed apk after update to 2.3 在Android studio中将UnitTest转换为Instrumentation Test - Converting UnitTest to Instrumentation Test in android studio JUNIT仪表测试在Android Studio中失败 - JUNIT instrumentation test failing in android studio Android Studio 中的 Android Instrumentation 测试和单元测试的区别? - Difference between Android Instrumentation test and Unit test in Android Studio? Android Studio 2.3未部署用户界面更改 - Android Studio 2.3 not deploying ui changes 使用 Room @Transaction 函数时,Android 仪器测试不会运行到结束 - Android instrumentation test doesn't run to end when using Room @Transaction function 使用espresso和ui automator在android studio 2.3中生成测试覆盖率报告 - Generate test coverage report in android studio 2.3 using espresso and ui automator Android Studio,如果按钮没有可绘制 - Android studio, if button doesn't have drawable Android Instrumentation测试用例 - Android Instrumentation Test Case
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM