Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing multiple activities with espresso

Is it possible to write tests across several activities using the android espresso framework?

like image 666
fernandohur Avatar asked Dec 06 '13 15:12

fernandohur


People also ask

What is espresso testing used for?

Espresso is a testing framework that helps developers write automation test cases for user interface (UI) testing. It has been developed by Google and aims to provide a simple yet powerful framework. It allows both black-box testing as well as testing of individual components during development cycles.

Is Espresso a testing tool?

Espresso created by Google is a native framework for Android automated testing. The tool is a part of the Android SDK and is easy to use for native mobile development.

Does espresso support test recording?

Espresso Test Recorder then takes the saved recording and automatically generates a corresponding UI test that you can run to test your app. Espresso Test Recorder writes tests based on the Espresso Testing framework, an API in AndroidX Test.


1 Answers

Yes, it is possible. In one of the samples they have demoed this here https://github.com/googlesamples/android-testing/blob/master/ui/espresso/BasicSample/app/src/androidTest/java/com/example/android/testing/espresso/BasicSample/ChangeTextBehaviorTest.java

@Test public void changeText_newActivity() {     // Type text and then press the button.     onView(withId(R.id.editTextUserInput)).perform(typeText(STRING_TO_BE_TYPED),             closeSoftKeyboard());     onView(withId(R.id.activityChangeTextBtn)).perform(click());      // This view is in a different Activity, no need to tell Espresso.     onView(withId(R.id.show_text_view)).check(matches(withText(STRING_TO_BE_TYPED))); } 

Read the inline comment.

Waiting for the new activity to load is taken care of implicitly by Espresso.

like image 128
Jigish Chawda Avatar answered Sep 29 '22 18:09

Jigish Chawda