Android Unit Test Androidx Migration (Kotlin)
December 28, 2018Cannot resolve symbol ‘AndroidJUnit4’
Change module build.gradle
.
android {
...
defaultConfig {
...
// testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}
dependencies {
testImplementation 'junit:junit:4.12'
// androidTestImplementation 'com.android.support.test:runner:1.0.2'
// androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation "androidx.test.ext:junit-ktx:1.1.0"
// androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
...
}
AndroidJUnit4.class is deprecated
androidx.test.runner.AndroidJUnit4 is deprecated. use androidx.test.ext.junit.runners.AndroidJUnit4
instead.
In module build.gradle
, make sure to replace com.android.support.test:runner:1.0.2
or androidx.test:runner:1.1.1
with androidx.test.ext:junit:1.1.0
.
Test running failed: Instrumentation run failed due to ‘java.lang.ClassNotFoundException’
Make sure to include androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.1'
.
References:
- algo-trading
- algolia
- analytics
- android
- android-ktx
- android-permission
- android-studio
- apps-script
- bash
- binance
- bootstrap
- bootstrapvue
- chartjs
- chrome
- cloud-functions
- coding-interview
- contentresolver
- coroutines
- crashlytics
- crypto
- css
- dagger2
- datastore
- datetime
- docker
- eslint
- firebase
- firebase-auth
- firebase-hosting
- firestore
- firestore-security-rules
- flask
- fontawesome
- fresco
- git
- github
- glide
- godot
- google-app-engine
- google-cloud-storage
- google-colab
- google-drive
- google-maps
- google-places
- google-play
- google-sheets
- gradle
- html
- hugo
- inkscape
- java
- java-time
- javascript
- jetpack-compose
- jetson-nano
- kotlin
- kotlin-serialization
- layout
- lets-encrypt
- lifecycle
- linux
- logging
- lubuntu
- markdown
- mate
- material-design
- matplotlib
- md5
- mongodb
- moshi
- mplfinance
- mysql
- navigation
- nginx
- nodejs
- npm
- nuxtjs
- nvm
- pandas
- payment
- pip
- pwa
- pyenv
- python
- recylerview
- regex
- room
- rxjava
- scoped-storage
- selenium
- social-media
- ssh
- ssl
- static-site-generator
- static-website-hosting
- sublime-text
- ubuntu
- unit-test
- uwsgi
- viewmodel
- viewpager2
- virtualbox
- vue-chartjs
- vue-cli
- vue-router
- vuejs
- vuelidate
- vuepress
- web-development
- web-hosting
- webpack
- windows
- workmanager
- wsl
- yarn