I am trying instrument an activity which will take the parameters from command line.
Launching App using Command line
adb shell am start -e "parameter" "test" -n com.test.example/.MainActivity
App Source code:
public class MainActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent().getExtras().getString("paramerter") == "test") {
//..other code
}
}
Instrumentation code:
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public final ActivityTestRule<MainActivity> rule =
new ActivityTestRule<>(MainActivity.class, true, false);
@Test
public void testLaunchActivity() throws Exception {
mActivityRule.getActivity();
}
}
How to pass the parameters to getActivity() ?