【问题标题】:Create Unit and Instrumentation test for Android project with dynamic features为具有动态功能的 Android 项目创建单元和仪器测试
【发布时间】:2020-03-16 16:30:03
【问题描述】:

我有一个项目,其中有 main :app 包。除此之外,该应用程序在同一个包中包含两个动态功能,:features:A 和:features:B。

这里的问题是由于以下错误,我无法运行单元和仪器测试(Espresso、UI Automator):

“AAPT: error: resource string/app_name (aka com.app.A.test:string/app_name) not found.” 

当我运行测试(在这种情况下为 UI 测试)时,应用程序编译并运行没有任何问题。

我发现清单合并时会发生错误,从完全错误中可以看出:

/Users/user/company/app/features/A/build/intermediates/tmp/manifest/androidTest/app/debug/manifestMerger7870721738992192959.xml:7:5-9:19: AAPT: error: resource string/app_name (aka com.app.A.test:string/app_name) not found.

【问题讨论】:

    标签: android testing gradle android-espresso android-uiautomator


    【解决方案1】:

    一个库(以上日志中的 A 或 B)需要在来自测试变体的合并清单中找到的某个值。要修复它,您需要在动态功能build.gradle中添加测试依赖:

    dependencies {
        implementation project(":app")
        androidTestImplementation project(":app")
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-22
      • 2017-11-02
      • 2011-04-05
      • 1970-01-01
      • 2019-08-25
      • 1970-01-01
      相关资源
      最近更新 更多