Espresso ActivityTestRule For Activity With Generic Type Parameter
I have declared an activity like this class QuestionnaireActivity : AppCompatActivity() I want to write an espresso test so I'm writting ActivityTestRule l
Solution 1:
similar to here the solution involves defining an inline function like this
inline fun <reified T: Activity> activityTestRuleWithIntent(intent: Intent) = object : ActivityTestRule<T>(T::class.java){
override fun getActivityIntent(): Intent = intent
}
then the rule becomes:
@Rule @JvmField
val rule = activityTestRuleWithIntent<QuestionnaireActivity<ProfileModel.LifeStyleInfo>>(QuestionnaireActivity.getQuestionnaireIntent(InstrumentationRegistry.getTargetContext(), 3, ProfileModel.LifeStyleInfo()))
Post a Comment for "Espresso ActivityTestRule For Activity With Generic Type Parameter"