I need to empty my user's data before each test
// Kotlin code
fun getActivity() = activityRule.getActivity()
Before
fun setUp() {
cleanUp(getActivity())
}
I need to get a Context in order to do so, but in setUp, activityRule.getActivity() returns null.
I also tried:
Before
fun setUp() {
val i = Intent()
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
activityRule.lauchActivity(i)
cleanUp(getActivity())
}
I got an activity, but cleanUp works only half of the time (I believe some race condition apply here)
I want to avoid to cleanUp in an After function in order to see manually my app state if needed.
Is there anyway to get a context in a Before function?
Thanks