?????????buildActivity??setupActivity?????????Activity?????????????????setupActivity????Activity????????????н?Σ???buildActivity?????????
????public static <T extends Activity> ActivityController<T> buildActivity(Class<T> activityClass) {
????return ActivityController.of(shadowsAdapter?? activityClass);
????}
????public static <T extends Activity> T setupActivity(Class<T> activityClass) {
????return ActivityController.of(shadowsAdapter?? activityClass).setup().get();
????}
????public ActivityController<T> setup() {
????return create().start().postCreate(null).resume().visible();
????}
??????2????????????
????ActivityController????Activity????????????????з?????????????Service?????????

??????3??????????
????Robolectric??????????????????Activity??е?????????????????MainActivity??д???????
MainActivity
button = (Button) findViewById(R.id.test1);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("Success");
}
});
TestDemoTest
@Before
public void beforeTest() throws Exception {
Log.i(TAG?? "beforeTest()");
mainActivity = Robolectric.buildActivity(MainActivity.class).setup().get();//???????????
button = (Button) mainActivity.findViewById(R.id.test1);
}
@Test
public void btn1(){
button.performClick();
}
??????Robolectric?д?Log?????**System.out**??Android??Log????????????Adb??????Ч??
??????4????????
????Robolectric????????Junit??assert??????????????????????????Junit??assert???????
????assertNotNull(); //?ж??????????
????assertNull();
????assertEquals(); //?ж???????????????“???”
????assertTrue(); //?ж?????????true
????assertFalse();
????assertNotSame();
????assertSame(); //?ж????????????????????????
??????5??????????????
???????????У????????????????????????????????????棬???????????????????????????????????????????????????????????е????????????????????????????????????????????????????????????????????????????????????????????case?б???б???????????е????????Χ?????????????????????????????????????б??м???????????????棬?????е?case????????????????????????????б???д??????????
??????????????????????????????????????????????????????????????????????????????????????д??????????????????????????и??????????????????????????????????case?б???????????????????в???case??
????????滮??????????????????????????????????????????????????????????


????