Reputation: 41
Here is it my sreen:
What settings should I set? How to avoid deprecated class?
I would like to use espresso, after that try to use UiAutomator, how to set needed necessary settings?
I lost almost whole day.
@RunWith(AndroidJUnit4::class)
@LargeTest
class MainActivityTest {
@Rule
@JvmField
var activityTest = ActivityTestRule(MainActivity::class.java)
fun c(){
assertEquals(1,1)
}
}
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.example.network"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
//okhttp library
implementation("com.squareup.okhttp3:okhttp:4.7.2")
// coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.7'
//gson
implementation 'com.google.code.gson:gson:2.8.6'
//recycler
implementation "androidx.recyclerview:recyclerview:1.1.0"
//picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//broadcast
implementation 'com.android.support:design:26.1.0'
//interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.7.0'
}
Upvotes: 0
Views: 381
Reputation: 18002
You've not set the test runner correctly.
This line:
"android.support.test.runner.AndroidJUnitRunner"
should be instead:
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
as you are using the new androidx
libraries instead of the old support
ones.
Without this you'll get this No tests were found
errors. Don't forget to add the testInstrumentationRunner
keyword.
And add junit to androidTestImplementation also in de gradle file:
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
Upvotes: 1