Ich wollte folgenden Test durchführen:
package com.xxx.yyy;
import Android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.Android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.xxx.yyy", appContext.getPackageName());
}
}
Ich bekomme aber den Fehler in der Konsole:
$ adb Shell am instrument -w -r -e debug false -e class 'com.xxx.yyy.ExampleInstrumentedTest' com.xxx.yyy.test/Android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests
Test running failed: Instrumentation run failed due to 'Process crashed.'
Empty test suite.
Ich kann nicht herausfinden, warum es nicht funktioniert.
Hier ist meine Gradle-Datei:
apply plugin: 'com.Android.application'
apply plugin: 'kotlin-Android'
apply plugin: 'org.greenrobot.greendao' // das kann dann später weg
//apply plugin: 'kotlin-kapt' // if using Kotlin
//apply plugin: 'io.objectbox'
Android {
compileSdkVersion 28
defaultConfig {
applicationId "com.xxx.yyy"
minSdkVersion 21
targetSdkVersion 28
versionCode 130
versionName "1.3.0"
testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
}
}
}
greendao {
schemaVersion 4
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.Android.material:material:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'org.greenrobot:greendao:3.2.2'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-ads:15.0.1'
testImplementation 'junit:junit:4.12'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.Android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'com.Android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.Android.support.test:runner:1.0.2'
androidTestImplementation 'com.Android.support.test:rules:1.0.2'
}
apply plugin: 'com.google.gms.google-services'
Irgendwelche Vorschläge?
Ich habe die Lösung von mir selbst gefunden . Ich habe auf AndroidX aktualisiert, deshalb musste ich auch meine Gradle-Datei von: .__ aktualisieren. testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner" bis testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Ich verstehe:
Test running failed: Instrumentation run failed due to 'Process crashed.'
in meinem Fall zeigt Android Testkonsole nur den obigen Fehler ohne Details an
aber, in logcat werden fehlerhafte Details angezeigt, in meinem Fall, weil ich vergessen habe, admob app_id in AndroidManifest.xml hinzuzufügen
damit
siehe logcat für Fehlerdetails
siehe logcat für Fehlerdetails
siehe logcat für Fehlerdetails
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.1'
abgesehen von der androidx.test.runner.AndroidJunitRunner-Konfiguration überprüfen Sie bitte auch die Abhängigkeit. Der obige Code ist für mich gearbeitet.