有没有人想出如何使用fragmentScenario Espresso 单独测试动态功能模块中的 fragment ,其中应用程序的 Activity 位于基本模块中。
我已经克服了几个问题,例如提示样式不是 Theme.Appcompat 和 Android Studio 没有运行,但现在 withId
在运行时提示找不到 R.id
在 fragment 的布局中。
最佳答案
我通过创建 AndroidManifest.xml
来解决动态模块中的仪器测试问题。在文件夹 src/debug
动态模块和放置:
<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 小型仪器测试的测试上。如果您需要在像 suggested here 这样的端到端测试中测试交付本身,我不确定这是否会产生影响,但如果有影响,您仍然可以为您的端到端测试创建一种风格,再次覆盖 list 。
关于android - 动态功能模块中 Fragments 的 fragmentScenario Espresso 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58827785/