android - ActivityTestRule.getActivity returns null in Before method -
i need empty user's data before each test
// kotlin code fun getactivity() = activityrule.getactivity() before fun setup() { cleanup(getactivity()) }
i need context in order so, in setup, activityrule.getactivity() returns null.
i tried:
before fun setup() { val = intent() i.addflags(intent.flag_activity_clear_top) activityrule.lauchactivity(i) cleanup(getactivity()) }
i got activity, cleanup works half of time (i believe race condition apply here)
i want avoid cleanup in after function in order see manually app state if needed.
is there anyway context in before function?
thanks
you can context instrumentationregistry calling gettargetcontext() method.
Comments
Post a Comment