Warum kann ich nicht importieren AndroidJUnit4 und ActivityTestRule in meinem unit-test-Klasse?

Ich habe Probleme beim importieren von einigen der Android-UI-testing-framework von clases - ich kann einfach nicht herausfinden, was Los ist falsch!

Das ist meine Klasse:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleUnitTest {

@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);

@Test
public void listGoesOverTheFold() {
    onView(withText("Hello world!")).check(matches(isDisplayed()));
  }
}

Aber aus irgendeinem Grund bekomme ich Fehler 'kann nicht finden das symbol ActivityTestRule' und 'kann nicht finden das symbol AndroidJUnit4'. Ich habe versucht, um Sie zu importieren, aber Sie können nicht gefunden werden.

Abhängigkeiten bauen.gradle eingestellt sind:

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
androidTestCompile 'com.android.support:support-annotations:23.4.0'

androidTestCompile 'com.android.support.test:runner:0.4'
androidTestCompile 'com.android.support.test:rules:0.4'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'

So, ich glaube, ich habe alle Abhängigkeiten setup - ich habe versucht, viele Dinge, aber kein Glück.

Jemand irgendwelche Ideen?

In welchem Verzeichnis ist der test-Klasse in - test/java oder androidTest/java?
Es ist unter test/java
Was ist, wenn mein test ist in androidTest/java, und ich bin mit diesem problem?

InformationsquelleAutor Hallupa | 2016-06-14

Schreibe einen Kommentar