[英]fragmentScenario Espresso tests of Fragments in Dynamic feature modules
有没有人想出如何使用fragmentScenario Espresso 单独测试动态功能模块中的片段,其中应用程序的活动位于基本模块中。
我已经克服了几个问题,例如抱怨样式不是 Theme.Appcompat 和 Android Studio 没有运行,但现在withId
在运行时抱怨它在片段布局中找不到R.id
。
我通过在动态模块的文件夹src/debug
中创建AndroidManifest.xml
并放置以下内容来解决动态模块中的仪器测试问题:
<manifest xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.poc.auth">
<!-- Note that we replace here our delivery from `on-demand` to `install-time` and put on the debug
folder so in tests this performs as a monolithic application and avoid non found
errors. Note also that this manifest need to be in `debug` folder rather
than `androidTest` folder. See https://stackoverflow.com/questions/26244998/androidmanifest-in-androidtest-directory-being-ignored-->
<dist:module
dist:instant="false"
dist:title="Feature Module Auth Test"
tools:node="replace">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="true" />
</dist:module>
</manifest>
这将使应用程序在测试中作为整体.apk
工作,这对于本地和CI/CD小型仪器测试非常有用。
如果您需要像这里建议的那样在端到端测试中测试交付本身,我不确定这是否会产生影响,但如果有影响,您仍然可以为您的端到端测试创造一种风格再次覆盖清单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.