After #1176 is closed we can start to migrate to use androidx.test:
Primarily this means (or could mean):
RuntimeEnvironment.application with ApplicationProvider.getApplicationContext()com.android.support.test to androidx.testRobolectricTestRunner in favor of AndroidJUnitRunner from androidx.testandroid.enableUnitTestBinaryResources=trueIf this is still a relevant task, I can take it.
@ArazAbishov Yeah, there are still a bunch of places left where we need to migrate. Feel free to open a PR. Small PRs that only cover a subset of the repository are easier to review and get in - don't try to migrate everything at once! :)
@pocmo Sure, that makes sense :)
@pocmo service-telemetry tests are written in Java. I'm fixing deprecated dependencies in it. May I gradually convert 'em to Kotlin as well?
Upd. Or event better: convert module sources to Kotlin at first so we can use tooling (compiler warnings, detekt, ktlint etc) with it.
@dector The telemetry library is going to be replaced with glean in the future (it's already used by Fenix and Reference Browser). To be honest I wouldn't touch it at all until we can delete it. It's well tested and still used by some apps.
@pocmo Cool, got it. So it's probably make no sense to fix deprecation warnings in tests there?
yeah, let's leave it alone unless there's a strong reason that improves the quality of other modules and has a low risk for the telemetry library itself.
Little migrating instructions manual for myself:
build.gradle:android {} block addtestOptions.unitTests.includeAndroidResources = true
dependencies {} block addtestImplementation Dependencies.androidx_test_junit
dependencies {} block removetestImplementation Dependencies.testing_junit
gradle.properties:# TODO remove and enable globally
android.enableUnitTestBinaryResources=true
or copy it from browser-awesomebar/gradle.properties :cat: .
@RunWith(RobolectricTestRunner::class) with @RunWith(AndroidJUnit4::class). Make sure that androidx.test.ext.junit.runners.AndroidJUnit4 is imported (not deprecated one).ApplicationProvider.getApplicationContext() calls with testContext (requires testImplementation project(':support-test'))._Note_: Don't remove Dependencies.testing_robolectric from dependencies even if it's not used. For some reasons tests are failing on CI because of this (but works locally).
@dector
Regarding testOptions.unitTests.includeAndroidResources = true. I assume once we are done we can define this in the root build.gradle for all Android projects (like we setup other defaults)?
Regarding
testOptions.unitTests.includeAndroidResources = true. I assume once we are done we can define this in the root build.gradle for all Android projects (like we setup other defaults)?
Yes, it definitely should be configured in allprojects {}.
@dector Can you group some of those changes into a single PR in the future? That's a lot of PRs and they all need to be merged manually and will all trigger a build for every PR and merge :)
@pocmo Sure. I was following original request. :)
Small PRs that only cover a subset of the repository are easier to review and get in
Anyway, I think only few modules left.