1

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() ?

Lava Sangeetham
  • 2,943
  • 4
  • 38
  • 54
  • 1
    Possible duplicate of [Start Activity for testing](http://stackoverflow.com/questions/30191715/start-activity-for-testing) – MyDogTom Oct 16 '16 at 19:11

0 Answers0