Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between Robolectric.setupActivity() and Robolectric.buildActivity()?

I am new to the Robolectric ,please help me understand it , what is the difference between these

loginActivity = new LoginActivity();
loginActivity = Robolectric.setupActivity(LoginActivity.class);
loginActivity = Robolectric.buildActivity(LoginActivity.class).create().start().resume().get();
like image 285
Lalit Behera Avatar asked Apr 22 '15 15:04

Lalit Behera


1 Answers

You should take a look at the implementation of the setup method. After following the call hierarchy you will find the following lines

Robolectric class method setup()

return ActivityController.of(shadowsAdapter, activityClass).setup().get(); 

ActivityController class method setup()

return create().start().postCreate(null).resume().visible();

No you can compare your custom call chain with the chain from setup method. Here is the code: https://github.com/robolectric/robolectric/blob/770f4bc5a95a58ea1cd1238e4b1d51977b1bb17a/robolectric/src/main/java/org/robolectric/util/ActivityController.java#L210

like image 60
nenick Avatar answered Nov 10 '22 16:11

nenick