Android espresso匹配意图与bundle内的bundle

时间:2016-11-30 23:49:29

标签: android-intent android-espresso android-testing hamcrest

我正在尝试匹配捆绑包(see image)内的值。

我需要验证是否设置了 uriString =" file:///storage/emulated...."

但到目前为止,使用我的代码,我可以验证值[1] ="仅由" 提供的福利卡。

intended(IntentMatchers.hasExtras(BundleMatchers.hasValue(hasExtras(BundleMatchers.hasValue("test - Prescription Card")))));

1 个答案:

答案 0 :(得分:0)

虽然这是旧的并且可能已经解决,但我认为尝试将 hasExtras 与嵌套的 hasEntry 一起使用是值得注意的。

对于像 -> extras: [Bundle[{key=Bundle[<more data>]}]] 这样的嵌套包 可以试试 -> hasExtras(hasEntry(<key>), hasEntry(<key>, <arg>))