Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Created October 4, 2018 12:03
Show Gist options
  • Save sonOfRa/7334b66f1df611920509d80a0441fa0f to your computer and use it in GitHub Desktop.
Save sonOfRa/7334b66f1df611920509d80a0441fa0f to your computer and use it in GitHub Desktop.
package de.wiberry.ci.testthing;
import android.support.test.filters.LargeTest;
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.*;
import static android.support.test.espresso.assertion.ViewAssertions.*;
import static android.support.test.espresso.matcher.ViewMatchers.*;
@LargeTest
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
/**
* Create the activity that is to be tested
*/
@Rule
public ActivityTestRule<MainActivity> mainActivityActivityTestRule = new ActivityTestRule<>(MainActivity.class);
/**
* Dummy test for correct text in default view
*/
@Test
public void mainActivityHelloWorld() {
onView(withId(R.id.hello)).check(matches(withText("Hello World!")));
}
@Test
public void mainActivitySecondButton() {
onView(withId(R.id.buttonTwo)).perform(click());
onView(withId(R.id.hello)).check(matches(withText("Goodbye World!")));
}
@Test
public void mainActivityRButton() {
onView(withId(R.id.buttonOne)).perform(click());
onView(withId(R.id.hello)).check(matches(withText("Goodbye World!")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment