basic espresso testSanity() working locally and on was device farm

This commit is contained in:
Antonio Zugaldia
2015-09-14 17:04:55 -04:00
parent 6f7aa10609
commit 9a0d12e142
2 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.mapbox.mapboxgl.testapp;
import android.support.test.InstrumentationRegistry;
import android.test.ActivityInstrumentationTestCase2;
import org.junit.Before;
/**
* Base Espresso class for all tests, helps working with ActivityInstrumentationTestCase2
*/
public class BaseTest
extends ActivityInstrumentationTestCase2<MainActivity> {
private MainActivity mActivity;
public BaseTest() {
super(MainActivity.class);
}
@Before
public void setUp() throws Exception {
super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
mActivity = getActivity();
}
}

View File

@@ -0,0 +1,27 @@
package com.mapbox.mapboxgl.testapp;
import org.junit.Test;
import static android.support.test.espresso.Espresso.onView;
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;
/**
* Tests MainActivity
*/
public class MainActivityTest extends BaseTest {
/*
* Note that we need to keep the `test` prefix if we want to be able to run these
* tests on AWS Device Farm, annotations are not enough:
* https://github.com/awslabs/aws-device-farm-sample-app-for-android/issues/5#issuecomment-138258444
*/
@Test
public void testSanity() {
onView(withId(R.id.layout_map))
.check(matches(isDisplayed()));
}
}