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

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -