Category : android-espresso

I’ve been using a BaseTest class for Espresso something like this : abstract class BaseTest<T : Activity> { val context: Context = InstrumentationRegistry.getInstrumentation().targetContext abstract fun getTestActivity(): IntentsTestRule<T> abstract fun startIntentActivity() @Rule @JvmField var activityTestRule = this.getTestActivity() fun launchActivity(intent: Intent?) { getTestActivity().launchActivity(intent) } @Before fun setUp() { startIntentActivity() } @After fun tearDown() { activityTestRule.finishActivity() } } ..

Read more

I’m practicing making an app with Room and LiveData, Basicly using this codeLab resource but just wrapped the list for recyclerView into a PagedList. This is what my adapter looks like: Adapter public class WordListAdapter extends PagedListAdapter<Word, WordListAdapter.ViewHolder> { private static final String TAG = WordListAdapter.class.getSimpleName(); public WordListAdapter(MyOnClickListener listener){ super(DIFF_CALLBACK); } @Override public ViewHolder onCreateViewHolder(ViewGroup ..

Read more

In the following android test fragment test class, https://github.com/TheReprator/UITestLearning/blob/master/app/src/androidTest/kotlin/com/example/uitest/FragmentDataBindingBTest.kt Only testDataBindingObserverValue() passed and other 2 fail(testDataBindingBDefaultValue(), testDataBindingBDefaultValue_updatedValue()), Ideally i am expecting, that i should be able to receive the initial value and then the new updated value, so i am atleast trying to make testDataBindingBDefaultValue_updatedValue(), test case to pass. My github Repo is as follows, ..

Read more

I wanted to create a custom regex matcher for Espresso so that I can check if the text on the screen contains time in format like HH:mm for example 23:34 or 04:23 I have a regex matcher class: class RegexMatcher(private val regex: String) : BoundedMatcher<View, TextView>(TextView::class.java) { private val pattern = Pattern.compile(regex) override fun describeTo(description: ..

Read more

Using this guide to test dialog https://developer.android.com/guide/fragments/test The bottom sample with(launchFragment<MyDialogFragment>()) { onFragment { fragment -> // here error assertThat(fragment.dialog).isNotNull() assertThat(fragment.requireDialog().isShowing).isTrue() fragment.dismiss() fragment.parentFragmentManager.executePendingTransactions() assertThat(fragment.dialog).isNull() } } But here it shows error onFragment { fragment -> // error below Type mismatch. Required: FragmentScenario.FragmentAction Found: (???) → Unit Cannot infer a type for this parameter. Please specify ..

Read more