How can you correctly put this test into the method:

onView(allOf(withId(R.id.textView), withHint(R.string.ui_common_email))) .perform(replaceText(AcceptanceConstants.TEST_NAME), closeSoftKeyboard()) 

Under correctly means that the arguments of this test will change, therefore I will have to use different arguments each time in the created method.

I try something like this:

  fun someMethod(String id, String text, String textar) { onView(allOf(withId(R.id.textView), withHint(AcceptanceConstants.FULL_NAME))) .perform(replaceText(AcceptanceConstants.TEST_NAME), closeSoftKeyboard()) } 

and then call it:

 someMethod(сюда параметры уже через запятую) 

    2 answers 2

    Well, if you are going to later change the parameters, then, respectively, in the method, pass the values ​​you want to change. I see you are using fun which means it's kotlin, not java.

    Well, in more detail it will look like this:

     fun updateValidationViewText(id: String, hint: String, newText: String) { Espresso.onView(Matchers.allOf(ViewMatchers.withId(id), ViewMatchers.withHint(hint))) .perform(ViewActions.replaceText(newText), ViewActions.closeSoftKeyboard()) } 

    And after that you call your method, where you need it, with the parameters you specify.

      You can send a link to activate.

      For example:

       private class SomeHelper { public void someMethod(Activity myActivity, String id, String text, String textar) { myActivity.onView(allOf(withId(R.id.textView), withHint(AcceptanceConstants.FULL_NAME))) .perform(replaceText(AcceptanceConstants.TEST_NAME), closeSoftKeyboard()) } }