Espresso攔截不到Intent,Recorded intents:[]
阿新 • • 發佈:2018-11-01
使用Espresso Intent 測試時,Recorded intents一直是空的,一直找不到原因,折騰了幾天才發現Espresso.Intents和Jpush有衝突,使用的是Jpush SDK3.0.8
Activity程式碼:
Espresso Intents UI測試程式碼:
報錯
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: Wanted to match 1 intents. Actually matched 0 intents.
IntentMatcher: has component: has component with: class name: an instance of java.lang.String package name: an instance of java.lang.String short class name: is ".activity.PublishRepairActivity"
Matched intents:[]
Recorded intents:[]
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
發現是Application中對Jpush進行了初始化造成的,具體為什麼會有衝突,不太清楚
解決方案:
註釋掉Jpush的初始化,再跑測試就通過了
發了幾封郵件給極光,但並沒有沒有得到解決方案,可能目前國內不太注重自動化測試,懶得去折騰了