update instrumentation test to JUnit4

This commit is contained in:
Vincent Breitmoser 2015-06-14 12:12:28 +02:00
parent 46e75a085e
commit 442aed8a2d
2 changed files with 10 additions and 3 deletions

View File

@ -143,9 +143,8 @@ android {
// Reference them in .xml files. // Reference them in .xml files.
resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account" resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
// Disabled: only works for androidTest not test!
// Enable code coverage (Jacoco) // Enable code coverage (Jacoco)
//testCoverageEnabled true testCoverageEnabled true
} }
} }

View File

@ -17,11 +17,16 @@
package org.sufficientlysecure.keychain; package org.sufficientlysecure.keychain;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.test.ActivityInstrumentationTestCase2; import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest; 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.Before;
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;
@ -40,6 +45,7 @@ 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 @LargeTest
public class CreateKeyActivityTest extends ActivityInstrumentationTestCase2<CreateKeyActivity> { public class CreateKeyActivityTest extends ActivityInstrumentationTestCase2<CreateKeyActivity> {
@ -52,12 +58,14 @@ public class CreateKeyActivityTest extends ActivityInstrumentationTestCase2<Crea
super(CreateKeyActivity.class); super(CreateKeyActivity.class);
} }
@Override @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
injectInstrumentation(InstrumentationRegistry.getInstrumentation());
getActivity(); 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))