Skip to content

Instantly share code, notes, and snippets.

@cawfree
Created August 18, 2017 09:47
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 cawfree/528159dbb8526e83ab15947d0c692bf2 to your computer and use it in GitHub Desktop.
Save cawfree/528159dbb8526e83ab15947d0c692bf2 to your computer and use it in GitHub Desktop.
/**
* Created by Alexander Thomas (@Cawfree) on 06/03/2017.
* This class is used to benchmark base functionality with the connected device we'll be using for testing.
*/
// Run using JUnit4.
@RunWith(AndroidJUnit4.class)
public class InitializeTest {
/** Test whether we have access to the base application context. */
@Test public final void testAcquireContext() throws Exception {
// Context of the app under test.
final Context lContext = InstrumentationRegistry.getTargetContext();
// Ensure that the package name matches the expectation for the test. (We must use a staging environment!)
Assert.assertEquals("your.package.name", lContext.getPackageName());
// Wake the device up.
UiDevice.getInstance(getInstrumentation()).wakeUp();
}
}
// Run using JUnit4. Expectation is that the user has already configured Browns app and allowed permissions, etc.
@RunWith(AndroidJUnit4.class)
public class SignUpTest {
// Ensure the VenueActivity has loaded.
@Rule public ActivityTestRule<VenueActivity> mVenueActivityRule = new ActivityTestRule<>(VenueActivity.class);
/** Tests if the user is able to sign up. */
@Test public final void testSignUp() throws Exception {
... etc...
// Relies on: (@Gradle)
dependencies {
// Testing API Dependencies.
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'junit:junit:4.12'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment