首页 > 解决方案 > Esspresso assertThat 在验证导航时需要额外的匹配器

问题描述

我正在按照Google 的示例使用模拟 navControllor 测试我的片段。我做的一切都是一样的,我在使用 assertThat 时从 Espresso 收到这个错误。我收到的错误消息

看来我需要传入一个不在 Google 提供的示例中的附加匹配器。我不知道为什么需要这个匹配器。

我的依赖版本:

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

任何帮助表示赞赏!谢谢!

标签: androidtestingandroid-espresso

解决方案


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

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

推荐阅读