Good IntentTestRule is not working properly. So I will try to do this with an ActivityTestRule :
public ActivityTestRule<MyActivity> activityTestRule = new ActivityTestRule<MyActivity>(MyActivity.class, false, false);
And then I will write the correct UI Unit Test to be something like this:
@Test public void testDeeplinkingFilledValue(){ Intent intent = new Intent(InstrumentationRegistry.getInstrumentation() .getTargetContext(), MyActivity.class ); Uri data = new Uri.Builder().appendQueryParameter("clientName", "Client123").build(); intent.setData(data); Intents.init(); activityTestRule.launchActivity(intent); intended(allOf( hasComponent(new ComponentName(getTargetContext(), MyActivity.class)), hasExtras(allOf( hasEntry(equalTo("clientName"), equalTo("Client123")) )))); Intents.release(); }
With this, you are going to verify that de-engineering with the given request parameter is actually correctly restored by your activity, which processes the intent for deeplinking.
denis_lor
source share