Skip to content

Instantly share code, notes, and snippets.

@doilio
Last active August 30, 2018 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doilio/17ab03cdeb6928bfc354604427c75977 to your computer and use it in GitHub Desktop.
Save doilio/17ab03cdeb6928bfc354604427c75977 to your computer and use it in GitHub Desktop.
Teste com Espresso
package com.example.android.conversa;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
@RunWith(AndroidJUnit4.class)
public class EspressoUITest {
@Rule
public ActivityTestRule mActivityRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testarActivities(){
onView(withId(R.id.enviar)).perform(click());
onView(withId(R.id.titulo1)).check(matches(isDisplayed()));
onView(withId(R.id.enviar1)).perform(click());
onView(withId(R.id.titulo)).check(matches(isDisplayed()));
}
@Test
public void testeInputOutput(){
onView(withId(R.id.mensagem)).perform(typeText("I've heard that Rosario is Batman"));
onView(withId(R.id.enviar)).perform(click());
onView(withId(R.id.mensagem_recebida1)).check(matches(withText("I've heard that Rosario is Batman")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment