Ich habe Probleme beim Importieren einiger Framework-Klassen für Android-UI-Tests - ich kann einfach nicht herausfinden, was schief läuft!Warum kann ich AndroidJUnit4 und ActivityTestRule nicht in meine Unit-Testklasse importieren?
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 Symbol ActivityTestRule finden' und 'nicht-Symbol AndroidJUnit4 finden'. Ich habe versucht, sie zu importieren, aber sie können nicht gefunden werden.
Die Abhängigkeiten in build.gradle gesetzt sind: - viele Dinge versucht, aber ohne Glück ich habe
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'
Also ich denke, ich alle Abhängigkeiten Setup haben.
Wer hat irgendwelche Ideen?
Was Verzeichnis ist Ihre Testklasse in - 'Test/java' oder' androidTest/java'? – Jahnold
Es ist im Test/Java – Hallupa