Esspresso assert验证导航时需要添加Matcher



我以谷歌为例,用模拟navController测试我的片段。我做的一切都一样,我在使用assertThat时从Espresso收到了这个错误。错误消息我得到了

似乎我需要传入一个额外的匹配器,这不是谷歌提供的示例。我不知道为什么需要这个火柴。

我的依赖版本:

androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

感谢您的帮助!谢谢

文档中的assertThat来自Truth,您可以通过Gradle依赖项将其添加到项目中:

androidTestImplementation "com.google.truth:truth:1.0.1"

最新更新