Android?е???????
???????????? ???????[ 2014/12/19 16:56:13 ] ??????????????? ???????
????Robolectric????????????????
????Robolectric?????javassist?????????????Android.jar?????byte code??Robolectric????JVM????Android.jar?????????д????????????Roblectroic??????Щ?????з??????null????0??????????????????????Щ???????????Shadow Objects?????Android SDK??????Shadow Objects??Robolectric???????????Android.jar??????????е?????????????????????????????????????????assert???????в????????????Robolectric?????????Shadow Objects???????????????????о???????????????????
????Robolectric?????
????????Robolectric??????????????????test runner??RobolectricTestRunner???????У??????????????RobolectricTestRunner??????????????test runner???????乹???????趨????????AndroidManifest.xml??resource?????磺
????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<WebPageActivity>)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??????н???????С???????????????????????????????????????????????????????????????????????????д?????????????????????????????????????????????????????????????????и???????????????и??????????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11