Junior — Middle
Have you created automated tests for the user interface?
sobes.tech AI
Answer from AI
Yes, I have created automated tests for the user interface on Android. Typically, tools such as Espresso or UI Automator are used for this.
Here's an example of a simple test using Espresso:
import androidx.test.espresso.Espresso;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.assertion.ViewAssertions;
import androidx.test.espresso.matcher.ViewMatchers;
// Check that clicking the button displays the text
Espresso.onView(ViewMatchers.withId(R.id.my_button))
.perform(ViewActions.click());
Espresso.onView(ViewMatchers.withId(R.id.my_text_view))
.check(ViewAssertions.matches(ViewMatchers.withText("Hello, world!")));
Such tests help automatically verify the correctness of the interface after code changes and speed up the regression testing process.