fix instrumentation test(s)

This commit is contained in:
Vincent Breitmoser 2015-06-13 21:50:57 +02:00
parent 66e7876abd
commit 5e4842ab64
2 changed files with 21 additions and 14 deletions

View File

@ -21,10 +21,14 @@ dependencies {
testCompile 'org.robolectric:robolectric:3.0-rc3' testCompile 'org.robolectric:robolectric:3.0-rc3'
// UI testing with Espresso // UI testing with Espresso
androidTestCompile 'com.android.support.test:runner:0.2' androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.2' androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.1' androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
// Temporary workaround for bug: https://code.google.com/p/android-test-kit/issues/detail?id=136 // Temporary workaround for bug: https://code.google.com/p/android-test-kit/issues/detail?id=136
// from https://github.com/googlesamples/android-testing/blob/master/build.gradle#L21 // from https://github.com/googlesamples/android-testing/blob/master/build.gradle#L21

View File

@ -17,14 +17,11 @@
package org.sufficientlysecure.keychain; package org.sufficientlysecure.keychain;
import android.support.test.rule.ActivityTestRule; import android.test.ActivityInstrumentationTestCase2;
import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest;
import android.text.method.HideReturnsTransformationMethod; import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod; import android.text.method.PasswordTransformationMethod;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity; import org.sufficientlysecure.keychain.ui.CreateKeyActivity;
import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.Espresso.onView;
@ -43,18 +40,24 @@ import static org.hamcrest.Matchers.allOf;
import static org.sufficientlysecure.keychain.matcher.EditTextMatchers.withError; import static org.sufficientlysecure.keychain.matcher.EditTextMatchers.withError;
import static org.sufficientlysecure.keychain.matcher.EditTextMatchers.withTransformationMethod; import static org.sufficientlysecure.keychain.matcher.EditTextMatchers.withTransformationMethod;
@RunWith(AndroidJUnit4.class) @LargeTest
public class CreateKeyActivityTest { public class CreateKeyActivityTest extends ActivityInstrumentationTestCase2<CreateKeyActivity> {
public static final String SAMPLE_NAME = "Sample Name"; public static final String SAMPLE_NAME = "Sample Name";
public static final String SAMPLE_EMAIL = "sample_email@gmail.com"; public static final String SAMPLE_EMAIL = "sample_email@gmail.com";
public static final String SAMPLE_ADDITIONAL_EMAIL = "sample_additional_email@gmail.com"; public static final String SAMPLE_ADDITIONAL_EMAIL = "sample_additional_email@gmail.com";
public static final String SAMPLE_PASSWORD = "sample_password"; public static final String SAMPLE_PASSWORD = "sample_password";
@Rule public CreateKeyActivityTest() {
public ActivityTestRule<CreateKeyActivity> mActivityRule = new ActivityTestRule<>(CreateKeyActivity.class); super(CreateKeyActivity.class);
}
@Override
public void setUp() throws Exception {
super.setUp();
getActivity();
}
@Test
public void testCreateMyKey() { public void testCreateMyKey() {
// Clicks create my key // Clicks create my key
onView(withId(R.id.create_key_create_key_button)) onView(withId(R.id.create_key_create_key_button))