I have an activity for holding a fragment. I created this for being able to run Deep Link to the profile. Also I pass PROFILE_ID as a query parameter. So the whole deep link looks this: "tigranes://home/profile?profileId=3545664".
class ProfileActivity : BaseActivity() {
companion object {
@JvmStatic
fun newInstance(context: Context, profileId: String): Intent {
val intent = Intent(context, ProfileActivity::class.java)
intent.putExtra(ProfileFragment.PROFILE_ID, profileId)
return intent
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val profileId: String = intent.getStringExtra(ProfileFragment.PROFILE_ID)
val transaction = supportFragmentManager.beginTransaction()
val fragment = ProfileFragment.newInstance(profileId)
transaction.add(R.id.fragment_container, fragment)
transaction.commit()
}
}
So my question is what will be the best strategy for writing test checking if this deep link is opening ProfileActivity. I tried to use ActivityTestRule but I wasn't able to find a way for passing a parameters to it.
if(savedInstanceState == null
otherwise you will have overlapping fragments. – KumamotoProfileActivity
looks alike, it might not lead to the desired result... you could still validate the answer by callinggetIntent()
. – Unipod