有没有人已经解决了如何使用fragmentScenario Espresso测试隔离动态功能模块中的片段,其中应用程序的活动位于基本模块中的问题。
我已经克服了一些问题,比如样式不是Theme.Appcompat和Android Studio无法运行,但现在withId
在运行时抱怨它无法在片段的布局中找到R.id
。
有没有人已经解决了如何使用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://dev59.com/H18d5IYBdhLWcg3w8WJt>
<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>
这将使应用程序在本地和CI/CD小仪器测试中作为单体.apk运行,非常适用。
如果您需要像此处建议的那样进行端到端测试以测试交付本身,我不确定这是否会产生影响,但如果有影响,您仍然可以为端到端测试创建一个口味,覆盖清单。
这真的很糟糕。 - Alaa
debugImplementation("androidx.fragment:fragment-testing:1.4.1")
之外,你还需要将其添加到应用程序模块中。 - Allan Veloso