I'm following this Google Codelab and at the page 8 (Task: End-to-End Testing with Data Binding), at step 8 (Write DataBindingIdlingResource) you have to create a file called DataBindingIdlingResource.kt.
class DataBindingIdlingResource : IdlingResource {
[...]
}
private fun View.getBinding(): ViewDataBinding? = DataBindingUtil.getBinding(this)
/**
* Sets the activity from an [ActivityScenario] to be used from [DataBindingIdlingResource].
*/
fun DataBindingIdlingResource.monitorActivity(
activityScenario: ActivityScenario<out FragmentActivity>
) {
activityScenario.onActivity {
this.activity = it
}
}
/**
* Sets the fragment from a [FragmentScenario] to be used from [DataBindingIdlingResource].
*/
fun DataBindingIdlingResource.monitorFragment(fragmentScenario: FragmentScenario<out Fragment>) {
fragmentScenario.onFragment {
this.activity = it.requireActivity()
}
}
The problem:
is the last function fun DataBindingIdlingResource.monitorFragment because fragmentScenario.onFragment provides only onFragment(action: Nothing) and not onFragment {}.
How Can I solve this issue? Thanks.
I've solved it by changing the definition to
fun <T : Fragment> DataBindingIdlingResource.monitorFragment(fragmentScenario: FragmentScenario<T>) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With