This is an automated archive made by the Lemmit Bot.

The original was posted on /r/androiddev by /u/BinkReddit on 2024-10-24 17:42:37+00:00.


From

We understand that many of you in the Android developer community have been asking for JUnit 5 support when running instrumented tests against your Android projects. We appreciate your passion for staying at the forefront of testing practices and incorporating the latest tools into your development workflow.

The desire to leverage JUnit5’s enhanced features and capabilities for Android instrumentation testing is entirely understandable. Therefore, we want to be transparent about the current challenges that prevent us from fully supporting JUnit5 for Android instrumentation tests at this time.

The Roadblocks

The primary hurdle lies in the deep-rooted integration of JUnit4 within the Android testing ecosystem. Our AndroidX Test libraries, Compose Test, and Benchmark libraries all rely heavily on JUnit4’s rules and runners. While creating JUnit5-compatible artifacts is technically achievable, there are clear challenges in the process.

To seamlessly support JUnit5, we would need to embark on a substantial undertaking:

Revamp the Core: Adapt the existing test runner or build a new one to proficiently discover and execute JUnit5 tests.

Parallel APIs: Develop a parallel set of JUnit5 APIs to mirror the functionality of the current JUnit4-based AndroidX Test APIs (e.g., ActivityScenarioRule).

Continuous Maintenance: Commit to ongoing maintenance efforts, including adding JUnit5 equivalents for every new API we introduce.

Robolectric Migration: Assist in migrating the Robolectric framework to support JUnit5, as it’s currently tightly coupled with JUnit4.

On top of those reasons, it is important to note that Google’s own internal testing infrastructure relies heavily on these same libraries. We want to maintain a level of uniformity within Google’s own infrastructure, and migrating to JUnit5 APIs will be a large and separate undertaking.

When we evaluated the benefits of JUnit5 against the effort and resources required to do it, both for internal Google testing infrastructure and for the broader Android developer community, we determined it doesn’t offer a big enough improvement for us to do it.

Looking Ahead

We remain committed to closely monitoring the evolving needs of the Android developer community. As the landscape shifts and resources permit, we’ll revisit the feasibility of full JUnit5 support for Android instrumentation tests.

In the meantime, we appreciate your understanding and patience as we navigate these complexities.