You can use:
intended(hasComponent(YourExpectedActivity.class.getName()));
Requires this gradle entry:
androidTestCompile ("com.android.support.test.espresso:espresso-intents:$espressoVersion")
The import for the intended()
and hasComponent()
import static android.support.test.espresso.intent.Intents.intended;
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent;
as mentioned by Shubam Gupta please remember to call Intents.init()
before calling intended()
. You can eventually call it in the @Before
method.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…