google-developer-training / advanced-android-testing

Android Testing Codelab
https://codelabs.developers.google.com/codelabs/android-testing/
Apache License 2.0
1.01k stars 677 forks source link

Instrumented tests are crashing in AS 4.1 when all libraries are updated to their respective versions. #162

Closed Zingam closed 4 years ago

Zingam commented 4 years ago

A.S. 4.1 Gradle 6.3 Android 10

Also why is this:

defaultConfig {
    applicationId "com.example.android.architecture.blueprints.reactive"
}

This causes the framwork to crash. It should be:

defaultConfig {
    applicationId "com.example.android.architecture.blueprints.todoapp"
}
dmeng commented 4 years ago

What branch are you seeing this on? Asking for repro purposes

Zingam commented 4 years ago

I initially started with the starter sample from the Udacity fork. I have modified it quite a bit and I also found out that these two cause issues:

debugImplementation "androidx.fragment:fragment-testing:$fragmentVersion"
implementation "androidx.test:core:$androidXTestCoreVersion"

Please find my own version attached: 1001-AndroidTesting.zip

dmeng commented 4 years ago

So, the immediate thing I'm noticing is that in your build.gradle, androidXTestRulesVersion and espressoVersion are on the latest version, but the rest of the AndroidXTest libraries are still on older versions. Assuming that the project is supposed to be using the latest libraries...

androidXTestCoreVersion,androidxTestRunner, androidXTestRulesVersion, and testRunner should all be at 1.3.0-beta01 androidXTestExtKotlinRunnerVersion should be at 1.1.2-beta01

Zingam commented 4 years ago

@dmeng I upgraded to AS 4.1 Canary 8. I didn't suggest any newer versions of the above libraries (I was previously relying on that feature) so I had to set them manually and the tests executed successfully. Thank you so much. Is there some guide how to select compatible version of libraries?

dmeng commented 4 years ago

We update the versions on all the libraries at the same time, so you'll always want to keep them on the same corresponding versions. Over in https://github.com/android/android-test/releases, we post those version numbers every time we release a new version.

(Though I admit, we don't have an explicit line for androidXTestExtKotlinRunnerVersion. Maybe we should. It's the AndroidX Test JUnit version number though.)

Zingam commented 4 years ago

This isn't very clear at least no for inexperienced people: https://github.com/android/android-test/releases https://developer.android.com/jetpack/androidx/releases/test

This description is much clearer:

https://developer.android.com/jetpack/androidx/releases/lifecycle

Thank you for your help!