Espresso assert 验证导航时需要额外的匹配器

Esspresso assertThat requires addtional Matcher when verifying navigation

我关注Google's example to test my fragment with a mock navControllor. I'm doing everything the same and I am getting this error from Espresso when using assertThat.Error message I got

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

我的依赖版本:

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"