android - Espresso Testing Multiple Activity -
i have apps, consist of 3 activites. first activity when can see list of data, second activity can see detail of data, , third can edit data. time wanna make instrument test using esspresso. case :
- show list, click 1 data
- detail data show on next activity
- choose edit button (edit button appear if check shared preferance login state)
i build apps using mvp , dagger. provide data test using dagger , mocking presenter. when move activity, cannot access shared preferance. looks injection work first activity.
here code: @before public void setup() throws exception {
app = (mainapplication) instrumentationregistry.getinstrumentation() .gettargetcontext().getapplicationcontext(); mainapplication.setappcomponent(daggertestappcomponent.builder() .testappmodule(new testappmodule(app)).build()); ((testappcomponent) app.getappcomponent()).inject(this); } @test public void editdata() { //it click , move activity onview(withid(r.id.list)) .perform(recyclerviewactions.actiononitematposition(0, click())); //i wanna click edit button, edit button appear if check shared preferance. presenter //it return null }
how make second activity injected , mocking too?
Comments
Post a Comment