Replace testImplementation by androidTestImplementation. So the tests on folder androidTest can have access to the library.
dependencies {
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
}
If you are not using androidx then use
android.arch.core:core-testing:1.1.1