2016-07-27 22 views
1

Ich habe Probleme mit AndroidJunit4.class importieren. Ich habe die Testklasse im Ordner androidTest/java/erstellt, aber es scheint, dass die Klasse nicht gefunden wird.AndroidJUnit4.class nicht in Instrumentation Tests gefunden

Auch wenn ich den richtigen Import erzwinge funktioniert es immer noch nicht. (importieren android.support.test. *).

@RunWith(AndroidJunit4.class) 
public class RandomTest { 

} 

Hier ist meine gradle:

defaultConfig { 
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 

dependencies { 
compile "com.android.support:support-annotations:23.4.0" 
compile "com.android.support:appcompat-v7:23.4.0" 
compile 'cat.ereza:customactivityoncrash:1.5.0' 
testCompile 'junit:junit:4.12' 
androidTestCompile 'junit:junit:4.12' 
androidTestCompile('com.android.support.test:runner:0.5') 
androidTestCompile('com.android.support.test:rules:0.5') 
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') 
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') 
androidTestCompile('com.android.support.test.espresso:espresso-intents:2.2.2') 

testCompile('com.android.support.test:runner:0.5') 
testCompile('com.android.support.test:rules:0.5') 
testCompile('com.android.support.test.espresso:espresso-core:2.2.2') 
testCompile('com.android.support.test.espresso:espresso-contrib:2.2.2') 
testCompile('com.android.support.test.espresso:espresso-intents:2.2.2') 

testCompile 'org.mockito:mockito-core:1.10.19' 
testCompile "org.robolectric:robolectric:3.1.1" 
} 

Seltsame ist, dass ich AndroidJunit4 Datei in meinem Projekt, aber in ihrer Mutter (AndroidJunit4ClassRunner), AndroidRunnerParams Klasse aufgelöst wird nicht einmal, wenn ich kann auch finden finde die Datei in meinem Projekt.

+0

Fügen Sie auch "testInstrumentationRunner" android.support.test.runner.AndroidJUnitRunner hinzu "' unter defaultConfig? – Egor

+0

Ja, ich habe es auch hinzugefügt, ich habe vergessen, es oben zu bemerken. – rct29

Antwort

0

Kommentieren Sie die Anmerkung

//@RunWith(AndroidJunit4.class) 

In Android Studio, wählen Sie "Build> Projekt neu"

die Anmerkung Erhalten Sie wieder in zurück

@RunWith(AndroidJunit4.class) 

ALT-ENTER -> Import Klasse