I am writing a test for my activity
MyActivity activity = new MyActivity();
activity.onCreate(null);
my activity expects and extra parameters to be passed, so when I call onCreate it crashes.
How can I pass an extra to my activity without using an Intent?
You could have the activity under test use some default values for the extra parameters, but I don’t recommend that approach. Instead, just have the test pass in the values.
From http://developer.android.com/reference/android/test/ActivityInstrumentationTestCase2.html#setActivityIntent(android.content.Intent)