????public class MyTestRunner extends RobolectricTestRunner {


????public MyTestRunner(Class testClass) throws InitializationError {

????super(testClass?? new RobolectricConfig(new File("my_app/AndroidManifest.xml")?? new File("my_app/res")));

????}

????}

?????????????test runner?? ?????????д???????Robolectric??????

????1 @RunWith(MyTestRunner.class)

 

????public class SignInScreenTest {


????@Test

????public void should_start_intent_when_click_registration_button() {


????2 Activity activity = new Activity();


????SignInScreen signInScreen = new SignInSceen(activity);


????3 TextView textView = (TextView) signInScreen.findViewById(R.id.sign_in_registration);


????textView.performClick();


????4 ShadowActivity shadowActivity = Robolectric.shadowOf(activity);


????Intent nextStartedActivity = shadowActivity.getNextStartedActivity();


????ShadowIntent shadowIntent = Robolectric.shadowOf(nextStartedActivity);


????assertThat((Class) shadowIntent.getIntentClass()?? equalTo(WebPageActivity.class));

????}

????}

????????β???????У?


????(1)????????????е?test runner;??????????????????????set up?? method invoke?????assert??????Ρ?


??????(2)?У??????????????Activity??????Context??????????Activity?????????????SignInScreen???;

 

???????????Σ????(3)?У??????????????????????????????????е????????????????????????????????????????????????????????????Implicit Intent????WebPageActivity??

 

??????????????????(4)?????????Robolectric????????shadowOf?????activity?????????Shadow Object ??????????Shadow Object??????????activity????????????Intent?????????Intent?????Shadow Object ?????????????intent class???????????

 

??????????????????????????????Robolectric???????????????????????Activity?????????xml?????????????????????????á????shadow???????????????Android???????????????????????????????????????????Intent?????????????????? Robolectric??????е?Dialog??HTTP???????????????????????в????


????Robolectric??????Android SDK?е???????????shadow???????????????? Robolectric.getDefaultShadowClasses() ?????????????????????????????????????shadow?????б??С?????????????????????ж???????????????????Shadow Objects??????Robolectric????????Robolectric???????????????????????

????????Robolectric??????????????Android??SDK??????JVM?????????????????????jUnit?????????IDE?л??????????ù???????????????????

????????Robolectric????2???????????????????????????Щ??????????????????Android4.0?????sonar?????????????????????????????github??fork??Robolectric??????????git submodule????????????????????????????????????????????????????????Robolectric?????????????????????? Robolectric?????????????????????????????????????????jar??????????jar???????????????????У??????????????????????????jar?????????????????????в????в???????Robolectric???????????????????????????

????????????????????????????????????????????????????????????????????BA???QA???й??????????????????????????QA???????????????????????????????cucumber????????д??????????????cuke4duke??jRuby??????н???????С???????????????????????????????????????????????????????????????????????????д?????????????????????????????????????????????????????????????????и???????????????и??????????????????????????????????????????????????????