Skip to content

Instantly share code, notes, and snippets.

@batmi02
Created August 27, 2020 20:41
Show Gist options
  • Save batmi02/889c30a55d228e12d4957a8aeb869587 to your computer and use it in GitHub Desktop.
Save batmi02/889c30a55d228e12d4957a8aeb869587 to your computer and use it in GitHub Desktop.
public class ExampleInstrumentedTest {
@rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);
@Test
public void simpleTeset() {
//Initialize the eyes SDK and set your private API key.
Eyes eyes = new Eyes();
eyes.setApiKey("YOUR_API_KEY");
try {
//start the test
eyes.open("Hello World!", "My first Espresso Android Test!");
//Visual checkpoint #1
eyes.checkWindow("Hello!");
onView(withID(R.id.click_me_btn)).perform(click());
//Visual checkpoint #2.
eyes.checkWindow("Click!");
//End the test
eyes.close();
} finally {
//if the test was aborted before eyes.close was called, end the test as aborted
eyes.abortIfNotClosed():
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment