It has been a day now that I am searching for a resolution to my problem, this is why I submit it.
I use Espresso to run Android tests. Everything works fine for Lollipop and newer, but for older Android versions (from API 16 that is the project's target to API 21 that is the first working version) it does not find the tests when I try to test in Android Studio. We use Travis as CI tool and the tests are running on Travis, so the first issue here is to make it work locally.
The second issue is that the files used for the tests are those in /androidTest folder for Android Lollipop and newer but for older versions it uses the default flavor that is the 'mock' flavor.
For example I have a class UserManager in both /mock and /androidTest folders, and I need the tests to use the one in /androidTest directory.
Do you know how to correct it? This breaks the tests only for Android 4.x, for newer versions the expected behavior happens so I am really disappointed.
I tried to set the sourceSets but it did not solve my issue.
I saw that multiDex could interfere with androidTest so I tried some solutions that were working for others but it did not fix it too.
I take any advise if someone can help.
Thanks
Android Studio 3.2.1
Gradle 4.6
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "my.app"
minSdkVersion 16
targetSdkVersion 28
versionCode Integer.parseInt(app_version_code)
versionName app_version_name
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
}
dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.json:json:20140107'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-intents:3.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
}
Aucun commentaire:
Enregistrer un commentaire