Adding a debug implementation to my gradle (then synch) makes my tests fail : def fragment_version = "1.2.5" debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
Here is my gradle : apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.micheladrien.fresquerappel"
minSdkVersion 22
targetSdkVersion 29
versionCode 12
versionName "1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
def navigation_version = '2.3.1'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
implementation 'il.co.theblitz:observablecollections:1.4.2'
def espressocore_version = '3.3.0'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressocore_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressocore_version"
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
androidTestImplementation "android.arch.core:core-testing:$lifecycle_version"
def mockito_version = '3.5.5' // For local unit tests on your development machine
testImplementation "org.mockito:mockito-core:$mockito_version" // For instrumentation tests on Android devices and emulators
androidTestImplementation "org.mockito:mockito-android:$mockito_version"
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support:support-annotations:24.0.0'
androidTestImplementation "androidx.navigation:navigation-testing:$navigation_version"
def fragment_version = "1.2.5"
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
}
Here is the result : Testing started at 16:01 ...
11/17 16:01:26: Launching 'testOpenSingleFrag...()' on LGE LG-H870S.
App restart successful without re-installing the following APK(s): com.micheladrien.fresquerappel
Running tests
$ adb shell am instrument -w -m -e debug false -e class 'com.micheladrien.android.fresquerappel.UITest.MainActivityTest#testOpenSingleFragment' com.micheladrien.fresquerappel.test/androidx.test.runner.AndroidJUnitRunner
Test running failed: Process crashed.
Tests ran to completion.
Removing the two last lines stop the tests from crashing. The app by outside of testing works just fine Does anyone have an idea why there is this issue ? Or any workaround to be able to execute launchFragmentInContainer() in my test file.
Thank you in advance for your help
Edit : additional informations that can be useful : there is only one build variant for my app, and that is debug.
Aucun commentaire:
Enregistrer un commentaire